From 6cb1394bb165aec3a7239454417a9327a31e0eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Fri, 10 Jul 2026 14:43:35 +0200 Subject: [PATCH] [COMCTL32][COMCTL32_WINETEST] Import wine implementation for PSN_QUERYINITIALFOCUS (#9272) Import patch from wine-9.15: wine-mirror/wine@786bb3b ``` comctl32: Add handling for PSN_QUERYINITIALFOCUS in prop.c. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54862 wine commit id 786bb3b993f7fe195adb732271df912286c5bfe7 by Jacob Czekalla ``` --- dll/win32/comctl32/propsheet.c | 40 ++++++++++++++++++- .../rostests/winetests/comctl32/propsheet.c | 22 +++++----- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/dll/win32/comctl32/propsheet.c b/dll/win32/comctl32/propsheet.c index 3a726565bdf..6cf2e305abe 100644 --- a/dll/win32/comctl32/propsheet.c +++ b/dll/win32/comctl32/propsheet.c @@ -37,7 +37,6 @@ * o WM_CONTEXTMENU * - Notifications: * o PSN_GETOBJECT - * o PSN_QUERYINITIALFOCUS * o PSN_TRANSLATEACCELERATOR * - Styles: * o PSH_RTLREADING @@ -195,6 +194,30 @@ static WCHAR *heap_strdupAtoW(const char *str) } #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");} + +#ifdef __REACTOS__ +static void PROPSHEET_SetInitialFocus(HWND hwndDlg, int index, PropSheetInfo* psInfo) +{ + PSHNOTIFY psn; + HWND focusable_item = NULL; + HWND initial_focus = NULL; + + focusable_item = GetNextDlgTabItem(psInfo->proppage[index].hwndPage, NULL, FALSE); + if (!focusable_item) + return; + + psn.hdr.code = PSN_QUERYINITIALFOCUS; + psn.hdr.hwndFrom = hwndDlg; + psn.hdr.idFrom = 0; + psn.lParam = 0; + initial_focus = (HWND)SendMessageW(psInfo->proppage[index].hwndPage, WM_NOTIFY, 0, (LPARAM)&psn); + if (initial_focus) + SetFocus(initial_focus); + else if (focusable_item) + SetFocus(focusable_item); +} +#endif // __REACTOS__ + /****************************************************************************** * PROPSHEET_UnImplementedFlags * @@ -1523,7 +1546,9 @@ static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo) { HWND hwndTabCtrl; HWND hwndLineHeader; +#ifndef __REACTOS__ HWND control; +#endif LPCPROPSHEETPAGEW ppshpage; TRACE("active_page %d, index %d\n", psInfo->active_page, index); @@ -1544,10 +1569,12 @@ static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo) { PROPSHEET_SetTitleW(hwndDlg, psInfo->ppshheader.dwFlags, psInfo->proppage[index].pszText); +#ifndef __REACTOS__ control = GetNextDlgTabItem(psInfo->proppage[index].hwndPage, NULL, FALSE); if(control != NULL) SetFocus(control); +#endif } if (psInfo->active_page != -1) @@ -1563,6 +1590,10 @@ static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo) psInfo->active_page = index; psInfo->activeValid = TRUE; +#ifdef __REACTOS__ + PROPSHEET_SetInitialFocus(hwndDlg, index, psInfo); +#endif + if (psInfo->ppshheader.dwFlags & (PSH_WIZARD97_OLD | PSH_WIZARD97_NEW) ) { hwndLineHeader = GetDlgItem(hwndDlg, IDC_SUNKEN_LINEHEADER); @@ -1761,6 +1792,9 @@ 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); +#ifdef __REACTOS__ + PROPSHEET_SetInitialFocus(hwndPage, psInfo->active_page, psInfo); +#endif } return TRUE; @@ -3699,7 +3733,11 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (psInfo->ppshheader.dwFlags & INTRNL_ANY_WIZARD) return FALSE; +#ifdef __REACTOS__ + return FALSE; +#else return TRUE; +#endif } case WM_PRINTCLIENT: diff --git a/modules/rostests/winetests/comctl32/propsheet.c b/modules/rostests/winetests/comctl32/propsheet.c index d7e54e84b84..461875f8f47 100644 --- a/modules/rostests/winetests/comctl32/propsheet.c +++ b/modules/rostests/winetests/comctl32/propsheet.c @@ -1251,25 +1251,25 @@ static void test_QueryInitialFocus(void) tab_ctrl = (HWND)SendMessageA(hp, PSM_GETTABCONTROL, 0, 0); /* Test PSN_QUERYINITIALFOCUS gets sent on start */ - todo_wine ok(query_initial_focus == 1, "Did not recieve PSN_QUERYINITIALFOCUS on start.\n"); - todo_wine ok(GetDlgCtrlID(GetFocus()) == IDC_PS_EDIT2, "Focus not set to IDC_PS_EDIT2.\n"); + ok(query_initial_focus == 1, "Did not recieve PSN_QUERYINITIALFOCUS on start.\n"); + ok(GetDlgCtrlID(GetFocus()) == IDC_PS_EDIT2, "Focus not set to IDC_PS_EDIT2.\n"); /* Test changing of tabs */ edit_test_ID = IDC_PS_EDIT1; query_initial_focus = 0; - todo_wine ok(tab_ctrl != 0, "Could not test changing tabs. No tab control found.\n"); + ok(tab_ctrl != 0, "Could not test changing tabs. No tab control found.\n"); SendMessageA(tab_ctrl, TCM_GETITEMRECT, 1, (LPARAM) &rc); lp = MAKELPARAM(rc.left + ((rc.right - rc.left) / 2), rc.top + ((rc.bottom - rc.top) / 2)); SendMessageA(tab_ctrl, WM_LBUTTONDOWN, MK_LBUTTON, lp); - todo_wine ok(query_initial_focus == 1, "Did not recieve PSN_QUERYINITIALFOCUS from changing tabs.\n"); - todo_wine ok(GetDlgCtrlID(GetFocus()) == IDC_PS_EDIT1, "Focus not set to IDC_PS_EDIT1.\n"); + ok(query_initial_focus == 1, "Did not recieve PSN_QUERYINITIALFOCUS from changing tabs.\n"); + ok(GetDlgCtrlID(GetFocus()) == IDC_PS_EDIT1, "Focus not set to IDC_PS_EDIT1.\n"); /* Test Apply Button */ edit_test_ID = IDC_PS_EDIT2; query_initial_focus = 0; SendMessageA(hp, PSM_PRESSBUTTON, PSBTN_APPLYNOW, 0); - todo_wine ok(query_initial_focus == 1, "Did not recieve PSN_QUERYINITIALFOCUS from apply button.\n"); - todo_wine ok(GetDlgCtrlID(GetFocus()) == IDC_PS_EDIT2, "Focus not set to IDC_PS_EDIT2.\n"); + ok(query_initial_focus == 1, "Did not recieve PSN_QUERYINITIALFOCUS from apply button.\n"); + ok(GetDlgCtrlID(GetFocus()) == IDC_PS_EDIT2, "Focus not set to IDC_PS_EDIT2.\n"); DestroyWindow(hp); @@ -1280,15 +1280,15 @@ static void test_QueryInitialFocus(void) hp = (HWND)pPropertySheetA(&psh); /* Test PSN_QUERYINITIALFOCUS gets sent on start */ - todo_wine ok(query_initial_focus == 1, "Did not recieve PSN_QUERYINITIALFOCUS on start.\n"); - todo_wine ok(GetDlgCtrlID(GetFocus()) == IDC_PS_EDIT1, "Focus not set to IDC_PS_EDIT1.\n"); + ok(query_initial_focus == 1, "Did not recieve PSN_QUERYINITIALFOCUS on start.\n"); + ok(GetDlgCtrlID(GetFocus()) == IDC_PS_EDIT1, "Focus not set to IDC_PS_EDIT1.\n"); /* Test Next Button */ edit_test_ID = IDC_PS_EDIT2; query_initial_focus = 0; SendMessageA(hp, PSM_PRESSBUTTON, PSBTN_NEXT, 0); - todo_wine ok(query_initial_focus == 1, "Did not recieve PSN_QUERYINITIALFOCUS from next button.\n"); - todo_wine ok(GetDlgCtrlID(GetFocus()) == IDC_PS_EDIT2, "Focus not set to IDC_PS_EDIT2.\n"); + ok(query_initial_focus == 1, "Did not recieve PSN_QUERYINITIALFOCUS from next button.\n"); + ok(GetDlgCtrlID(GetFocus()) == IDC_PS_EDIT2, "Focus not set to IDC_PS_EDIT2.\n"); DestroyWindow(hp); }