From: Jacob Czekalla jczekalla@codeweavers.com
--- dlls/comctl32/tests/propsheet.c | 105 ++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+)
diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c index 9bd1c08bd6a..262c6f9fc0d 100644 --- a/dlls/comctl32/tests/propsheet.c +++ b/dlls/comctl32/tests/propsheet.c @@ -1388,6 +1388,110 @@ static void test_invalid_hpropsheetpage(void) DestroyWindow(hdlg); }
+int query_initial_focus = 0; +LRESULT CALLBACK TestDlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam) +{ + LPNMHDR lpnmhdr; +switch (uMessage) + { + case WM_NOTIFY: + lpnmhdr = (NMHDR *)lParam; + switch (lpnmhdr->code) + { + case PSN_QUERYINITIALFOCUS: + { + query_initial_focus = 1; + break; + } + default: + break; + } + break; + + default: + break; + } + + return FALSE; + +} + +static void test_QueryInitialFocus(void) +{ + PROPSHEETPAGEA psp[2]; + PROPSHEETHEADERA psh; + HWND tab_ctrl = NULL; + HWND hp; + RECT rc; + LPARAM lp; + + memset(&psh, 0, sizeof(psh)); + memset(psp, 0, sizeof(psp[0]) * 2); + psp[0].dwSize = sizeof(PROPSHEETPAGEA); + psp[0].dwFlags = PSP_USETITLE; + psp[0].hInstance = GetModuleHandleA(NULL);; + psp[0].pszTemplate = (const char*) MAKEINTRESOURCE(IDD_PROP_PAGE_EDIT); + psp[0].pszIcon = NULL; + psp[0].pfnDlgProc = (DLGPROC) TestDlgProc; + psp[0].pszTitle = "Page1"; + psp[0].lParam = 0; + + psp[1].dwSize = sizeof(PROPSHEETPAGEA); + psp[1].dwFlags = PSP_USETITLE; + psp[1].hInstance = GetModuleHandleA(NULL); + psp[1].pszTemplate = (const char*) MAKEINTRESOURCE(IDD_PROP_PAGE_EDIT); + psp[1].pszIcon = NULL; + psp[1].pfnDlgProc = (DLGPROC) TestDlgProc; + psp[1].pszTitle = "Page2"; + 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); + tab_ctrl = (HWND)SendMessageA(hp, PSM_GETTABCONTROL, 0, 0); + + //Test PSN_QUERYINITIALFOCUS gets sent on start + ok(query_initial_focus, "Did not recieve PSN_QUERYINITIALFOCUS on start.\n"); + query_initial_focus = 0; + + //Test changing of tabs + ok(tab_ctrl != 0, "Could not test changing tabs. No tab control found.\n"); + if(tab_ctrl) + { + 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); + ok(query_initial_focus, "Did not recieve PSN_QUERYINITIALFOCUS from changing tabs.\n"); + query_initial_focus = 0; + } + + //Test Apply Button + SendMessageA(hp, PSM_PRESSBUTTON, PSBTN_APPLYNOW, 0); + ok(query_initial_focus, "Did not recieve PSN_QUERYINITIALFOCUS from apply button.\n"); + query_initial_focus = 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(query_initial_focus, "Did not recieve PSN_QUERYINITIALFOCUS on start.\n"); + query_initial_focus = 0; + + //Test Next Button + SendMessageA(hp, PSM_PRESSBUTTON, PSBTN_NEXT, 0); + ok(query_initial_focus, "Did not recieve PSN_QUERYINITIALFOCUS from next button.\n"); + query_initial_focus = 0; + + DestroyWindow(hp); +} + static void init_comctl32_functions(void) { HMODULE hComCtl32 = LoadLibraryA("comctl32.dll"); @@ -1442,6 +1546,7 @@ START_TEST(propsheet) test_CreatePropertySheetPage(); test_page_dialog_texture(); test_invalid_hpropsheetpage(); + test_QueryInitialFocus();
if (!load_v6_module(&ctx_cookie, &ctx)) return;