From 5ca21de331d3cbd89351622557fa6c0e45fbbb3c Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Tue, 14 Feb 2012 14:17:18 +0000 Subject: [PATCH] [COMCTL32] - If no control or one of wizard buttons has focus in PROPSHEET_SetWizButtons, set focus to default wizard button. Tested in Win2k3. Worse fix was already in diff but wasn't applied. svn path=/trunk/; revision=55593 --- reactos/dll/win32/comctl32/comctl32_ros.diff | 71 ++++++-------------- reactos/dll/win32/comctl32/propsheet.c | 30 ++++++--- 2 files changed, 40 insertions(+), 61 deletions(-) diff --git a/reactos/dll/win32/comctl32/comctl32_ros.diff b/reactos/dll/win32/comctl32/comctl32_ros.diff index 367bf2d6836..bdcdcaf50fb 100644 --- a/reactos/dll/win32/comctl32/comctl32_ros.diff +++ b/reactos/dll/win32/comctl32/comctl32_ros.diff @@ -125,37 +125,17 @@ Index: propsheet.c =================================================================== --- propsheet.c (revision 38890) +++ propsheet.c (working copy) -@@ -2417,6 +2417,29 @@ - return FALSE; - } +@@ -2425,6 +2425,9 @@ + HWND hwndBack = GetDlgItem(hwndDlg, IDC_BACK_BUTTON); + HWND hwndNext = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON); + HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON); ++ HWND hwndCancel = GetDlgItem(hwndDlg, IDCANCEL); ++ INT iDefItem = 0; ++ HWND hwndFocus; -+BOOL CALLBACK -+EnumChildProc(HWND hwnd, LPARAM lParam) -+{ -+ WCHAR szType[20]; -+ RealGetWindowClassW(hwnd, szType, 20); -+ -+ if (strcmpW(szType, WC_EDITW) == 0) -+ { -+ if (IsWindowEnabled(hwnd) && IsWindowVisible(hwnd)) -+ { -+ SetFocus(hwnd); -+ return FALSE; -+ } -+ } -+ else -+ { -+ EnumChildWindows(hwnd, EnumChildProc, 0); -+ } -+ -+ return TRUE; -+} -+ -+ - /****************************************************************************** - * PROPSHEET_SetWizButtons - * -@@ -2438,17 +2461,6 @@ + TRACE("%d\n", dwFlags); + +@@ -2432,17 +2435,6 @@ EnableWindow(hwndNext, FALSE); EnableWindow(hwndFinish, FALSE); @@ -173,35 +153,26 @@ Index: propsheet.c if (dwFlags & PSWIZB_BACK) EnableWindow(hwndBack, TRUE); -@@ -2478,6 +2490,31 @@ +@@ -2472,6 +2464,22 @@ } else if (!(dwFlags & PSWIZB_DISABLEDFINISH)) EnableWindow(hwndFinish, TRUE); + -+ /* set the default pushbutton to an enabled button and give it focus */ ++ /* set the default pushbutton to an enabled button */ + if (((dwFlags & PSWIZB_FINISH) || psInfo->hasFinish) && !(dwFlags & PSWIZB_DISABLEDFINISH)) -+ { -+ SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0); -+ SetFocus(hwndFinish); -+ } ++ iDefItem = IDC_FINISH_BUTTON; + else if (dwFlags & PSWIZB_NEXT) -+ { -+ SendMessageW(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0); -+ SetFocus(hwndNext); -+ } ++ iDefItem = IDC_NEXT_BUTTON; + else if (dwFlags & PSWIZB_BACK) -+ { -+ SendMessageW(hwndDlg, DM_SETDEFID, IDC_BACK_BUTTON, 0); -+ SetFocus(hwndBack); -+ } ++ iDefItem = IDC_BACK_BUTTON; + else -+ { -+ SendMessageW(hwndDlg, DM_SETDEFID, IDCANCEL, 0); -+ SetFocus(GetDlgItem(hwndDlg, IDCANCEL)); -+ } ++ iDefItem = IDCANCEL; ++ SendMessageW(hwndDlg, DM_SETDEFID, iDefItem, 0); + -+ /* Now try to find an edit control that deserves focus */ -+ EnumChildWindows(PropSheet_GetCurrentPageHwnd(hwndDlg), EnumChildProc, 0); ++ /* Set focus if no control has it */ ++ hwndFocus = GetFocus(); ++ if (!hwndFocus || hwndFocus == hwndCancel) ++ SetFocus(GetDlgItem(hwndDlg, iDefItem)); } /****************************************************************************** diff --git a/reactos/dll/win32/comctl32/propsheet.c b/reactos/dll/win32/comctl32/propsheet.c index 6f620c6c973..465c825167e 100644 --- a/reactos/dll/win32/comctl32/propsheet.c +++ b/reactos/dll/win32/comctl32/propsheet.c @@ -2425,6 +2425,9 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags) HWND hwndBack = GetDlgItem(hwndDlg, IDC_BACK_BUTTON); HWND hwndNext = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON); HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON); + HWND hwndCancel = GetDlgItem(hwndDlg, IDCANCEL); + INT iDefItem = 0; + HWND hwndFocus; TRACE("%d\n", dwFlags); @@ -2432,17 +2435,6 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags) EnableWindow(hwndNext, FALSE); EnableWindow(hwndFinish, FALSE); - /* set the default pushbutton to an enabled button */ - if (((dwFlags & PSWIZB_FINISH) || psInfo->hasFinish) && !(dwFlags & PSWIZB_DISABLEDFINISH)) - SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0); - else if (dwFlags & PSWIZB_NEXT) - SendMessageW(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0); - else if (dwFlags & PSWIZB_BACK) - SendMessageW(hwndDlg, DM_SETDEFID, IDC_BACK_BUTTON, 0); - else - SendMessageW(hwndDlg, DM_SETDEFID, IDCANCEL, 0); - - if (dwFlags & PSWIZB_BACK) EnableWindow(hwndBack, TRUE); @@ -2472,6 +2464,22 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags) } else if (!(dwFlags & PSWIZB_DISABLEDFINISH)) EnableWindow(hwndFinish, TRUE); + + /* set the default pushbutton to an enabled button */ + if (((dwFlags & PSWIZB_FINISH) || psInfo->hasFinish) && !(dwFlags & PSWIZB_DISABLEDFINISH)) + iDefItem = IDC_FINISH_BUTTON; + else if (dwFlags & PSWIZB_NEXT) + iDefItem = IDC_NEXT_BUTTON; + else if (dwFlags & PSWIZB_BACK) + iDefItem = IDC_BACK_BUTTON; + else + iDefItem = IDCANCEL; + SendMessageW(hwndDlg, DM_SETDEFID, iDefItem, 0); + + /* Set focus if no control has it */ + hwndFocus = GetFocus(); + if (!hwndFocus || hwndFocus == hwndCancel) + SetFocus(GetDlgItem(hwndDlg, iDefItem)); } /******************************************************************************