Adding PSN_QUERYINITIALFOCUS helped fix some focus issues with the property sheet in bug 54862. Previously the listview in the tab control did not get focus from the start when it should have.
From: Jacob Czekalla jczekalla@codeweavers.com
--- dlls/comctl32/propsheet.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c index b530a1a8094..5e62812b805 100644 --- a/dlls/comctl32/propsheet.c +++ b/dlls/comctl32/propsheet.c @@ -582,6 +582,24 @@ static void HPSP_draw_text(HPROPSHEETPAGE hpsp, HDC hdc, BOOL title, RECT *r, UI }
#define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");} + +static void notify_QueryInitialFocus(HWND hwndDlg, int index, PropSheetInfo* psInfo) +{ + PSHNOTIFY psn; + HWND hInitialFocus; + + psn.hdr.code = PSN_QUERYINITIALFOCUS; + psn.hdr.hwndFrom = hwndDlg; + psn.hdr.idFrom = 0; + psn.lParam = 0; + hInitialFocus = (HWND) SendMessageW(psInfo->proppage[index].hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); + + if (!hInitialFocus) + hInitialFocus = GetNextDlgTabItem(psInfo->proppage[index].hwndPage, NULL, FALSE); + if(hInitialFocus) + SetFocus(hInitialFocus); +} + /****************************************************************************** * PROPSHEET_UnImplementedFlags * @@ -1655,7 +1673,6 @@ static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo) { HWND hwndTabCtrl; HWND hwndLineHeader; - HWND control;
TRACE("active_page %d, index %d\n", psInfo->active_page, index); if (index == psInfo->active_page) @@ -1674,10 +1691,6 @@ static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo) { PROPSHEET_SetTitleW(hwndDlg, psInfo->ppshheader.dwFlags, psInfo->proppage[index].pszText); - - control = GetNextDlgTabItem(psInfo->proppage[index].hwndPage, NULL, FALSE); - if(control != NULL) - SetFocus(control); }
if (psInfo->active_page != -1) @@ -1693,6 +1706,8 @@ static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo) psInfo->active_page = index; psInfo->activeValid = TRUE;
+ notify_QueryInitialFocus(hwndDlg, index, psInfo); + if (psInfo->ppshheader.dwFlags & (PSH_WIZARD97_OLD | PSH_WIZARD97_NEW) ) { hwndLineHeader = GetDlgItem(hwndDlg, IDC_SUNKEN_LINEHEADER); @@ -1891,6 +1906,7 @@ static BOOL PROPSHEET_Apply(HWND hwndDlg, LPARAM lParam) psn.lParam = 0; hwndPage = psInfo->proppage[psInfo->active_page].hwndPage; SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); + notify_QueryInitialFocus(hwndPage, psInfo->active_page, psInfo); }
return TRUE;
From: Jacob Czekalla jczekalla@codeweavers.com
--- dlls/comctl32/tests/propsheet.c | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c index 9bd1c08bd6a..469b0b7a4eb 100644 --- a/dlls/comctl32/tests/propsheet.c +++ b/dlls/comctl32/tests/propsheet.c @@ -1388,6 +1388,86 @@ static void test_invalid_hpropsheetpage(void) DestroyWindow(hdlg); }
+int bQueryInitialFocus = 0; +LRESULT CALLBACK TestDlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam) +{ + LPNMHDR lpnmhdr = (NMHDR *)lParam; + if(lpnmhdr && lpnmhdr->code == PSN_QUERYINITIALFOCUS) + bQueryInitialFocus = 1; + + return FALSE; +} + +static void test_QueryInitialFocus(void) +{ + PROPSHEETPAGEA psp[2]; + PROPSHEETHEADERA psh; + HWND tabCtrl = NULL; + HWND hp; + RECT rc; + LPARAM lp; + + psp[0].dwSize = sizeof(PROPSHEETPAGEA); + psp[0].dwFlags = PSP_DEFAULT; + psp[0].hInstance = GetModuleHandleA(NULL);; + psp[0].pszTemplate = (const char*) MAKEINTRESOURCE(IDD_PROP_PAGE_INTRO); + psp[0].pfnDlgProc = (DLGPROC) TestDlgProc; + psp[0].lParam = 0; + + psp[1].dwSize = sizeof(PROPSHEETPAGEA); + psp[1].dwFlags = PSP_DEFAULT; + psp[1].hInstance = GetModuleHandleA(NULL); + psp[1].pszTemplate = (const char*) MAKEINTRESOURCE(IDD_PROP_PAGE_INTRO); + psp[1].pfnDlgProc = (DLGPROC) TestDlgProc; + psp[1].lParam = 0; + + psh.dwSize = sizeof(PROPSHEETHEADERA); + psh.dwFlags = PSH_PROPSHEETPAGE | PSH_MODELESS; + psh.hwndParent = GetDesktopWindow(); + psh.pszCaption = "Modeless Property Sheet"; + psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGEA); + psh.ppsp = (LPCPROPSHEETPAGEA)&psp; + + hp = (HWND) pPropertySheetA(&psh); + tabCtrl = (HWND)SendMessageA(hp, PSM_GETTABCONTROL, 0, 0); + + //Test PSN_QUERYINITIALFOCUS gets sent on start + ok(bQueryInitialFocus, "Did not recieve PSN_QUERYINITIALFOCUS on start.\n"); + bQueryInitialFocus = 0; + + //Test changing of tabs + ok(tabCtrl != 0, "Could not test changing tabs. No tab control found.\n"); + if(tabCtrl) + { + SendMessageA(tabCtrl, TCM_GETITEMRECT, 1, (LPARAM) &rc); + lp = MAKELPARAM(rc.left + ((rc.right-rc.left)/2), rc.top + ((rc.bottom-rc.top)/2)); + SendMessageA(tabCtrl, WM_LBUTTONDOWN, MK_LBUTTON, lp); + ok(bQueryInitialFocus, "Did not recieve PSN_QUERYINITIALFOCUS from changing tabs.\n"); + bQueryInitialFocus = 0; + } + + //Test Apply Button + SendMessageA(hp, PSM_PRESSBUTTON, PSBTN_APPLYNOW, 0); + ok(bQueryInitialFocus, "Did not recieve PSN_QUERYINITIALFOCUS from apply button.\n"); + bQueryInitialFocus = 0; + + DestroyWindow(hp); + + psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_WIZARD | PSH_MODELESS; + hp = (HWND) pPropertySheetA(&psh); + + //Test PSN_QUERYINITIALFOCUS gets sent on start + ok(bQueryInitialFocus, "Did not recieve PSN_QUERYINITIALFOCUS on start.\n"); + bQueryInitialFocus = 0; + + //Test Next Button + SendMessageA(hp, PSM_PRESSBUTTON, PSBTN_NEXT, 0); + ok(bQueryInitialFocus, "Did not recieve PSN_QUERYINITIALFOCUS from next button.\n"); + bQueryInitialFocus = 0; + + DestroyWindow(hp); +} + static void init_comctl32_functions(void) { HMODULE hComCtl32 = LoadLibraryA("comctl32.dll"); @@ -1442,6 +1522,7 @@ START_TEST(propsheet) test_CreatePropertySheetPage(); test_page_dialog_texture(); test_invalid_hpropsheetpage(); + test_QueryInitialFocus();
if (!load_v6_module(&ctx_cookie, &ctx)) return;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147303
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
comctl32: propsheet.c:1435: Test failed: Did not recieve PSN_QUERYINITIALFOCUS on start. propsheet.c:1445: Test failed: Did not recieve PSN_QUERYINITIALFOCUS from changing tabs. propsheet.c:1451: Test failed: Did not recieve PSN_QUERYINITIALFOCUS from apply button. 02c8:propsheet: unhandled exception c0000005 at 001CF66A
=== w7u_adm (32 bit report) ===
comctl32: 0870:propsheet: unhandled exception c0000005 at 013FF66A
=== w7u_el (32 bit report) ===
comctl32: 0a64:propsheet: unhandled exception c0000005 at 0116F66A
=== w8 (32 bit report) ===
comctl32: 0c68:propsheet: unhandled exception c0000005 at 008BF66A
=== w8adm (32 bit report) ===
comctl32: 0b1c:propsheet: unhandled exception c0000005 at 00A3F66A
=== w864 (32 bit report) ===
comctl32: 07dc:propsheet: unhandled exception c0000005 at 00BCF66A
=== w1064v1507 (32 bit report) ===
comctl32: 08d8:propsheet: unhandled exception c0000005 at 0034F66A
=== w1064v1809 (32 bit report) ===
comctl32: 1d84:propsheet: unhandled exception c0000005 at 0140F66A
=== w1064_tsign (32 bit report) ===
comctl32: 1e00:propsheet: unhandled exception c0000005 at 0059F66A
=== w10pro64 (32 bit report) ===
comctl32: 20e0:propsheet: unhandled exception c0000005 at 00D3F66A
=== w10pro64_en_AE_u8 (32 bit report) ===
comctl32: propsheet.c:1435: Test failed: Did not recieve PSN_QUERYINITIALFOCUS on start. propsheet.c:1445: Test failed: Did not recieve PSN_QUERYINITIALFOCUS from changing tabs. propsheet.c:1451: Test failed: Did not recieve PSN_QUERYINITIALFOCUS from apply button. 2244:propsheet: unhandled exception c0000005 at 0015F66A
=== w11pro64 (32 bit report) ===
comctl32: 1b64:propsheet: unhandled exception c0000005 at 001AF66A
=== w7pro64 (64 bit report) ===
comctl32: propsheet.c:1435: Test failed: Did not recieve PSN_QUERYINITIALFOCUS on start. propsheet.c:1445: Test failed: Did not recieve PSN_QUERYINITIALFOCUS from changing tabs. propsheet.c:1451: Test failed: Did not recieve PSN_QUERYINITIALFOCUS from apply button. 0618:propsheet: unhandled exception c0000005 at 00000000001DF1C5
=== w864 (64 bit report) ===
comctl32: 0914:propsheet: unhandled exception c0000005 at 000000000124F1C5
=== w1064v1507 (64 bit report) ===
comctl32: 0fb4:propsheet: unhandled exception c0000005 at 0000000000FEF1C5
=== w1064v1809 (64 bit report) ===
comctl32: 1f14:propsheet: unhandled exception c0000005 at 0000000000AAF1C5
=== w1064_2qxl (64 bit report) ===
comctl32: 1db8:propsheet: unhandled exception c0000005 at 000000000039F1C5
=== w1064_adm (64 bit report) ===
comctl32: propsheet.c:1435: Test failed: Did not recieve PSN_QUERYINITIALFOCUS on start. propsheet.c:1445: Test failed: Did not recieve PSN_QUERYINITIALFOCUS from changing tabs. propsheet.c:1451: Test failed: Did not recieve PSN_QUERYINITIALFOCUS from apply button. 0688:propsheet: unhandled exception c0000005 at 00000000000CF1C5
=== w1064_tsign (64 bit report) ===
comctl32: 1168:propsheet: unhandled exception c0000005 at 000000000024F1C5
=== w10pro64 (64 bit report) ===
comctl32: 201c:propsheet: unhandled exception c0000005 at 00000000006EF1C5
=== w10pro64_ar (64 bit report) ===
comctl32: 1060:propsheet: unhandled exception c0000005 at 000000000042F1C5
=== w10pro64_ja (64 bit report) ===
comctl32: 21f4:propsheet: unhandled exception c0000005 at 000000000039F1C5
=== w10pro64_zh_CN (64 bit report) ===
comctl32: 21a4:propsheet: unhandled exception c0000005 at 000000000017F1C5
=== w11pro64_amd (64 bit report) ===
comctl32: 22d4:propsheet: unhandled exception c0000005 at 0000000000DDF1C5
=== debian11b (64 bit WoW report) ===
Report validation errors: comctl32:propsheet crashed (c0000005)