From 93fe673fa4764c211da371ca886b7c45ba07149a Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sun, 29 Nov 2015 18:00:19 +0000 Subject: [PATCH] [SHELL32] Set the OK button in the run dialog as disabled by default unless text is added. By Mark Jansen. CORE-10436 svn path=/trunk/; revision=70206 --- reactos/dll/win32/shell32/dialogs/dialogs.cpp | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/reactos/dll/win32/shell32/dialogs/dialogs.cpp b/reactos/dll/win32/shell32/dialogs/dialogs.cpp index 34cf2106d2f..959fa238210 100644 --- a/reactos/dll/win32/shell32/dialogs/dialogs.cpp +++ b/reactos/dll/win32/shell32/dialogs/dialogs.cpp @@ -346,6 +346,27 @@ static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline) } } +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 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA 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,6 +494,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA 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)); } @@ -479,6 +502,14 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA return TRUE; } + case IDC_RUNDLG_EDITPATH: + { + if (HIWORD(wParam) == CBN_EDITCHANGE) + { + EnableOkButtonFromEditContents(hwnd); + } + return TRUE; + } } return TRUE; } -- 2.17.1