Author: akhaldi Date: Sun Nov 29 18:00:19 2015 New Revision: 70206
URL: http://svn.reactos.org/svn/reactos?rev=70206&view=rev Log: [SHELL32] Set the OK button in the run dialog as disabled by default unless text is added. By Mark Jansen. CORE-10436
Modified: trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp
Modified: trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/dialogs/d... ============================================================================== --- trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp [iso-8859-1] Sun Nov 29 18:00:19 2015 @@ -346,6 +346,27 @@ } }
+static void EnableOkButtonFromEditContents(HWND hwnd) +{ + BOOL Enable = FALSE; + INT Length, n; + HWND Edit = GetDlgItem(hwnd, IDC_RUNDLG_EDITPATH); + Length = GetWindowTextLengthA(Edit); + if (Length > 0) + { + PWCHAR psz = (PWCHAR)HeapAlloc(GetProcessHeap(), 0, (Length + 1) * sizeof(WCHAR)); + if (psz) + { + GetWindowTextW(Edit, psz, Length + 1); + for (n = 0; n < Length && !Enable; ++n) + Enable = psz[n] != ' '; + HeapFree(GetProcessHeap(), 0, psz); + } + else + Enable = TRUE; + } + EnableWindow(GetDlgItem(hwnd, IDOK), Enable); +}
/* Dialog procedure for RunFileDlg */ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -379,6 +400,7 @@ SendMessageW(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)prfdp->hIcon);
FillList (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH), NULL, (prfdp->uFlags & RFF_NODEFAULT) == 0); + EnableOkButtonFromEditContents(hwnd); SetFocus (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH)); return TRUE;
@@ -472,11 +494,20 @@ SetFocus (GetDlgItem (hwnd, IDOK)); SetWindowTextW (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH), szFName); SendMessageW (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH), CB_SETEDITSEL, 0, MAKELPARAM (0, -1)); + EnableOkButtonFromEditContents(hwnd); SetFocus (GetDlgItem (hwnd, IDOK)); }
FreeLibrary (hComdlg);
+ return TRUE; + } + case IDC_RUNDLG_EDITPATH: + { + if (HIWORD(wParam) == CBN_EDITCHANGE) + { + EnableOkButtonFromEditContents(hwnd); + } return TRUE; } }