[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
This commit is contained in:
Rafal Harabien 2012-02-14 14:17:18 +00:00
parent 3a2974ab60
commit 5ca21de331
2 changed files with 40 additions and 61 deletions

View file

@ -125,37 +125,17 @@ Index: propsheet.c
=================================================================== ===================================================================
--- propsheet.c (revision 38890) --- propsheet.c (revision 38890)
+++ propsheet.c (working copy) +++ propsheet.c (working copy)
@@ -2417,6 +2417,29 @@ @@ -2425,6 +2425,9 @@
return FALSE; 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 TRACE("%d\n", dwFlags);
+EnumChildProc(HWND hwnd, LPARAM lParam)
+{ @@ -2432,17 +2435,6 @@
+ 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 @@
EnableWindow(hwndNext, FALSE); EnableWindow(hwndNext, FALSE);
EnableWindow(hwndFinish, FALSE); EnableWindow(hwndFinish, FALSE);
@ -173,35 +153,26 @@ Index: propsheet.c
if (dwFlags & PSWIZB_BACK) if (dwFlags & PSWIZB_BACK)
EnableWindow(hwndBack, TRUE); EnableWindow(hwndBack, TRUE);
@@ -2478,6 +2490,31 @@ @@ -2472,6 +2464,22 @@
} }
else if (!(dwFlags & PSWIZB_DISABLEDFINISH)) else if (!(dwFlags & PSWIZB_DISABLEDFINISH))
EnableWindow(hwndFinish, TRUE); 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)) + if (((dwFlags & PSWIZB_FINISH) || psInfo->hasFinish) && !(dwFlags & PSWIZB_DISABLEDFINISH))
+ { + iDefItem = IDC_FINISH_BUTTON;
+ SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
+ SetFocus(hwndFinish);
+ }
+ else if (dwFlags & PSWIZB_NEXT) + else if (dwFlags & PSWIZB_NEXT)
+ { + iDefItem = IDC_NEXT_BUTTON;
+ SendMessageW(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0);
+ SetFocus(hwndNext);
+ }
+ else if (dwFlags & PSWIZB_BACK) + else if (dwFlags & PSWIZB_BACK)
+ { + iDefItem = IDC_BACK_BUTTON;
+ SendMessageW(hwndDlg, DM_SETDEFID, IDC_BACK_BUTTON, 0);
+ SetFocus(hwndBack);
+ }
+ else + else
+ { + iDefItem = IDCANCEL;
+ SendMessageW(hwndDlg, DM_SETDEFID, IDCANCEL, 0); + SendMessageW(hwndDlg, DM_SETDEFID, iDefItem, 0);
+ SetFocus(GetDlgItem(hwndDlg, IDCANCEL));
+ }
+ +
+ /* Now try to find an edit control that deserves focus */ + /* Set focus if no control has it */
+ EnumChildWindows(PropSheet_GetCurrentPageHwnd(hwndDlg), EnumChildProc, 0); + hwndFocus = GetFocus();
+ if (!hwndFocus || hwndFocus == hwndCancel)
+ SetFocus(GetDlgItem(hwndDlg, iDefItem));
} }
/****************************************************************************** /******************************************************************************

View file

@ -2425,6 +2425,9 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
HWND hwndBack = GetDlgItem(hwndDlg, IDC_BACK_BUTTON); HWND hwndBack = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
HWND hwndNext = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON); HWND hwndNext = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON); HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
HWND hwndCancel = GetDlgItem(hwndDlg, IDCANCEL);
INT iDefItem = 0;
HWND hwndFocus;
TRACE("%d\n", dwFlags); TRACE("%d\n", dwFlags);
@ -2432,17 +2435,6 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
EnableWindow(hwndNext, FALSE); EnableWindow(hwndNext, FALSE);
EnableWindow(hwndFinish, 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) if (dwFlags & PSWIZB_BACK)
EnableWindow(hwndBack, TRUE); EnableWindow(hwndBack, TRUE);
@ -2472,6 +2464,22 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
} }
else if (!(dwFlags & PSWIZB_DISABLEDFINISH)) else if (!(dwFlags & PSWIZB_DISABLEDFINISH))
EnableWindow(hwndFinish, TRUE); 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));
} }
/****************************************************************************** /******************************************************************************