2006-04-06 17:55:32 +02:00
|
|
|
/* Unit test suite for property sheet control.
|
|
|
|
*
|
|
|
|
* Copyright 2006 Huw Davies
|
2009-08-31 14:09:00 +02:00
|
|
|
* Copyright 2009 Jan de Mooij
|
2006-04-06 17:55:32 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-04-06 17:55:32 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
2010-11-06 09:54:12 +01:00
|
|
|
#include "msg.h"
|
2006-04-06 17:55:32 +02:00
|
|
|
|
2009-08-14 00:36:56 +02:00
|
|
|
#include "resources.h"
|
|
|
|
|
2006-04-06 17:55:32 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
2010-11-06 09:54:12 +01:00
|
|
|
static HWND parenthwnd;
|
2009-10-17 18:11:29 +02:00
|
|
|
static HWND sheethwnd;
|
2008-07-08 20:52:57 +02:00
|
|
|
|
2017-11-21 06:54:35 +01:00
|
|
|
static BOOL rtl;
|
2009-08-14 00:36:56 +02:00
|
|
|
static LONG active_page = -1;
|
|
|
|
|
2009-08-31 14:09:00 +02:00
|
|
|
#define IDC_APPLY_BUTTON 12321
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
static HPROPSHEETPAGE (WINAPI *pCreatePropertySheetPageA)(const PROPSHEETPAGEA *desc);
|
|
|
|
static HPROPSHEETPAGE (WINAPI *pCreatePropertySheetPageW)(const PROPSHEETPAGEW *desc);
|
|
|
|
static BOOL (WINAPI *pDestroyPropertySheetPage)(HPROPSHEETPAGE proppage);
|
|
|
|
static INT_PTR (WINAPI *pPropertySheetA)(const PROPSHEETHEADERA *header);
|
2011-09-06 00:13:38 +02:00
|
|
|
|
2017-11-21 06:54:35 +01:00
|
|
|
static void detect_locale(void)
|
|
|
|
{
|
|
|
|
DWORD reading_layout;
|
|
|
|
rtl = GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IREADINGLAYOUT | LOCALE_RETURN_NUMBER,
|
|
|
|
(void *)&reading_layout, sizeof(reading_layout)) && reading_layout == 1;
|
|
|
|
}
|
|
|
|
|
2011-09-06 00:13:38 +02:00
|
|
|
/* try to make sure pending X events have been processed before continuing */
|
|
|
|
static void flush_events(void)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
int diff = 200;
|
|
|
|
int min_timeout = 100;
|
|
|
|
DWORD time = GetTickCount() + diff;
|
|
|
|
|
|
|
|
while (diff > 0)
|
|
|
|
{
|
|
|
|
if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
|
2013-11-04 17:47:32 +01:00
|
|
|
while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
|
2011-09-06 00:13:38 +02:00
|
|
|
diff = time - GetTickCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-06 17:55:32 +02:00
|
|
|
static int CALLBACK sheet_callback(HWND hwnd, UINT msg, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch(msg)
|
|
|
|
{
|
2017-01-13 12:25:54 +01:00
|
|
|
case PSCB_PRECREATE:
|
|
|
|
{
|
|
|
|
HMODULE module = GetModuleHandleA("comctl32.dll");
|
|
|
|
DWORD size, buffer_size;
|
|
|
|
HRSRC hrsrc;
|
|
|
|
|
|
|
|
hrsrc = FindResourceA(module, MAKEINTRESOURCEA(1006 /* IDD_PROPSHEET */),
|
|
|
|
(LPSTR)RT_DIALOG);
|
|
|
|
size = SizeofResource(module, hrsrc);
|
|
|
|
ok(size != 0, "Failed to get size of propsheet dialog resource\n");
|
|
|
|
buffer_size = HeapSize(GetProcessHeap(), 0, (void *)lparam);
|
|
|
|
ok(buffer_size == 2 * size, "Unexpected template buffer size %u, resource size %u\n",
|
|
|
|
buffer_size, size);
|
|
|
|
break;
|
|
|
|
}
|
2006-04-06 17:55:32 +02:00
|
|
|
case PSCB_INITIALIZED:
|
|
|
|
{
|
|
|
|
char caption[256];
|
|
|
|
GetWindowTextA(hwnd, caption, sizeof(caption));
|
|
|
|
ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
|
2009-10-17 18:11:29 +02:00
|
|
|
sheethwnd = hwnd;
|
2006-04-06 17:55:32 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2009-10-17 18:11:29 +02:00
|
|
|
|
2006-04-06 17:55:32 +02:00
|
|
|
static INT_PTR CALLBACK page_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
|
|
|
|
LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
HWND sheet = GetParent(hwnd);
|
|
|
|
char caption[256];
|
|
|
|
GetWindowTextA(sheet, caption, sizeof(caption));
|
|
|
|
ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
NMHDR *nmhdr = (NMHDR *)lparam;
|
|
|
|
switch(nmhdr->code)
|
|
|
|
{
|
|
|
|
case PSN_APPLY:
|
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2009-10-17 18:11:29 +02:00
|
|
|
case WM_NCDESTROY:
|
|
|
|
ok(!SendMessageA(sheethwnd, PSM_INDEXTOHWND, 400, 0),"Should always be 0\n");
|
|
|
|
return TRUE;
|
|
|
|
|
2006-04-06 17:55:32 +02:00
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_title(void)
|
|
|
|
{
|
|
|
|
HPROPSHEETPAGE hpsp[1];
|
|
|
|
PROPSHEETPAGEA psp;
|
|
|
|
PROPSHEETHEADERA psh;
|
|
|
|
HWND hdlg;
|
2011-09-08 00:33:29 +02:00
|
|
|
DWORD style;
|
2006-04-06 17:55:32 +02:00
|
|
|
|
|
|
|
memset(&psp, 0, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = 0;
|
2009-10-28 14:57:22 +01:00
|
|
|
psp.hInstance = GetModuleHandleA(NULL);
|
2006-11-23 21:33:06 +01:00
|
|
|
U(psp).pszTemplate = "prop_page1";
|
|
|
|
U2(psp).pszIcon = NULL;
|
2006-04-06 17:55:32 +02:00
|
|
|
psp.pfnDlgProc = page_dlg_proc;
|
|
|
|
psp.lParam = 0;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[0] = pCreatePropertySheetPageA(&psp);
|
2006-04-06 17:55:32 +02:00
|
|
|
|
|
|
|
memset(&psh, 0, sizeof(psh));
|
2011-09-06 00:21:04 +02:00
|
|
|
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
|
2006-04-06 17:55:32 +02:00
|
|
|
psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK;
|
|
|
|
psh.pszCaption = "test caption";
|
|
|
|
psh.nPages = 1;
|
|
|
|
psh.hwndParent = GetDesktopWindow();
|
2006-11-23 21:33:06 +01:00
|
|
|
U3(psh).phpage = hpsp;
|
2006-04-06 17:55:32 +02:00
|
|
|
psh.pfnCallback = sheet_callback;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hdlg = (HWND)pPropertySheetA(&psh);
|
2011-07-06 11:49:14 +02:00
|
|
|
ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle value %p\n", hdlg);
|
|
|
|
|
2013-11-04 17:47:32 +01:00
|
|
|
style = GetWindowLongA(hdlg, GWL_STYLE);
|
2011-09-08 00:33:29 +02:00
|
|
|
ok(style == (WS_POPUP|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CAPTION|WS_SYSMENU|
|
|
|
|
DS_CONTEXTHELP|DS_MODALFRAME|DS_SETFONT|DS_3DLOOK),
|
|
|
|
"got unexpected style: %x\n", style);
|
|
|
|
|
2006-04-06 17:55:32 +02:00
|
|
|
DestroyWindow(hdlg);
|
|
|
|
}
|
|
|
|
|
2007-04-03 19:58:19 +02:00
|
|
|
static void test_nopage(void)
|
|
|
|
{
|
|
|
|
HPROPSHEETPAGE hpsp[1];
|
|
|
|
PROPSHEETPAGEA psp;
|
|
|
|
PROPSHEETHEADERA psh;
|
2011-09-06 00:13:38 +02:00
|
|
|
HWND hdlg, hpage;
|
|
|
|
MSG msg;
|
2007-04-03 19:58:19 +02:00
|
|
|
|
|
|
|
memset(&psp, 0, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = 0;
|
2009-10-28 14:57:22 +01:00
|
|
|
psp.hInstance = GetModuleHandleA(NULL);
|
2007-04-03 19:58:19 +02:00
|
|
|
U(psp).pszTemplate = "prop_page1";
|
|
|
|
U2(psp).pszIcon = NULL;
|
|
|
|
psp.pfnDlgProc = page_dlg_proc;
|
|
|
|
psp.lParam = 0;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[0] = pCreatePropertySheetPageA(&psp);
|
2007-04-03 19:58:19 +02:00
|
|
|
|
|
|
|
memset(&psh, 0, sizeof(psh));
|
2011-09-06 00:21:04 +02:00
|
|
|
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
|
2007-04-03 19:58:19 +02:00
|
|
|
psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK;
|
|
|
|
psh.pszCaption = "test caption";
|
|
|
|
psh.nPages = 1;
|
|
|
|
psh.hwndParent = GetDesktopWindow();
|
|
|
|
U3(psh).phpage = hpsp;
|
|
|
|
psh.pfnCallback = sheet_callback;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hdlg = (HWND)pPropertySheetA(&psh);
|
2011-07-06 11:49:14 +02:00
|
|
|
ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle value %p\n", hdlg);
|
|
|
|
|
2007-04-03 19:58:19 +02:00
|
|
|
ShowWindow(hdlg,SW_NORMAL);
|
2013-11-04 17:47:32 +01:00
|
|
|
SendMessageA(hdlg, PSM_REMOVEPAGE, 0, 0);
|
|
|
|
hpage = /* PropSheet_GetCurrentPageHwnd(hdlg); */
|
|
|
|
(HWND)SendMessageA(hdlg, PSM_GETCURRENTPAGEHWND, 0, 0);
|
|
|
|
active_page = /* PropSheet_HwndToIndex(hdlg, hpage)); */
|
|
|
|
(int)SendMessageA(hdlg, PSM_HWNDTOINDEX, (WPARAM)hpage, 0);
|
|
|
|
ok(hpage == NULL, "expected no current page, got %p, index=%d\n", hpage, active_page);
|
2011-09-06 00:13:38 +02:00
|
|
|
flush_events();
|
2007-04-03 19:58:19 +02:00
|
|
|
RedrawWindow(hdlg,NULL,NULL,RDW_UPDATENOW|RDW_ERASENOW);
|
2011-09-06 00:13:38 +02:00
|
|
|
|
|
|
|
/* Check that the property sheet was fully redrawn */
|
2013-11-04 17:47:32 +01:00
|
|
|
ok(!PeekMessageA(&msg, 0, WM_PAINT, WM_PAINT, PM_NOREMOVE),
|
2011-09-06 00:13:38 +02:00
|
|
|
"expected no pending WM_PAINT messages\n");
|
2007-04-03 19:58:19 +02:00
|
|
|
DestroyWindow(hdlg);
|
|
|
|
}
|
|
|
|
|
2008-07-08 20:52:57 +02:00
|
|
|
static int CALLBACK disableowner_callback(HWND hwnd, UINT msg, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case PSCB_INITIALIZED:
|
|
|
|
{
|
2010-11-06 09:54:12 +01:00
|
|
|
ok(IsWindowEnabled(parenthwnd) == 0, "parent window should be disabled\n");
|
2008-07-08 20:52:57 +02:00
|
|
|
PostQuitMessage(0);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void register_parent_wnd_class(void)
|
|
|
|
{
|
|
|
|
WNDCLASSA cls;
|
|
|
|
|
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = DefWindowProcA;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(NULL);
|
|
|
|
cls.hIcon = 0;
|
2013-11-04 17:47:32 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
|
2008-07-08 20:52:57 +02:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "parent class";
|
|
|
|
RegisterClassA(&cls);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_disableowner(void)
|
|
|
|
{
|
|
|
|
HPROPSHEETPAGE hpsp[1];
|
|
|
|
PROPSHEETPAGEA psp;
|
|
|
|
PROPSHEETHEADERA psh;
|
2009-11-19 11:53:28 +01:00
|
|
|
INT_PTR p;
|
2008-07-08 20:52:57 +02:00
|
|
|
|
|
|
|
register_parent_wnd_class();
|
2010-11-06 09:54:12 +01:00
|
|
|
parenthwnd = CreateWindowA("parent class", "", WS_CAPTION | WS_SYSMENU | WS_VISIBLE, 100, 100, 100, 100, GetDesktopWindow(), NULL, GetModuleHandleA(NULL), 0);
|
2008-07-08 20:52:57 +02:00
|
|
|
|
|
|
|
memset(&psp, 0, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = 0;
|
2009-10-28 14:57:22 +01:00
|
|
|
psp.hInstance = GetModuleHandleA(NULL);
|
2008-07-08 20:52:57 +02:00
|
|
|
U(psp).pszTemplate = "prop_page1";
|
|
|
|
U2(psp).pszIcon = NULL;
|
|
|
|
psp.pfnDlgProc = NULL;
|
|
|
|
psp.lParam = 0;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[0] = pCreatePropertySheetPageA(&psp);
|
2008-07-08 20:52:57 +02:00
|
|
|
|
|
|
|
memset(&psh, 0, sizeof(psh));
|
2011-09-06 00:21:04 +02:00
|
|
|
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
|
2008-07-08 20:52:57 +02:00
|
|
|
psh.dwFlags = PSH_USECALLBACK;
|
|
|
|
psh.pszCaption = "test caption";
|
|
|
|
psh.nPages = 1;
|
2010-11-06 09:54:12 +01:00
|
|
|
psh.hwndParent = parenthwnd;
|
2008-07-08 20:52:57 +02:00
|
|
|
U3(psh).phpage = hpsp;
|
|
|
|
psh.pfnCallback = disableowner_callback;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
p = pPropertySheetA(&psh);
|
2009-11-19 11:53:28 +01:00
|
|
|
ok(p == 0, "Expected 0, got %ld\n", p);
|
2010-11-06 09:54:12 +01:00
|
|
|
ok(IsWindowEnabled(parenthwnd) != 0, "parent window should be enabled\n");
|
|
|
|
DestroyWindow(parenthwnd);
|
2008-07-08 20:52:57 +02:00
|
|
|
}
|
|
|
|
|
2009-08-18 14:49:21 +02:00
|
|
|
static INT_PTR CALLBACK nav_page_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
2009-08-14 00:36:56 +02:00
|
|
|
{
|
|
|
|
switch(msg){
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
LPNMHDR hdr = (LPNMHDR)lparam;
|
|
|
|
switch(hdr->code){
|
|
|
|
case PSN_SETACTIVE:
|
2013-11-04 17:47:32 +01:00
|
|
|
active_page = /* PropSheet_HwndToIndex(hdr->hwndFrom, hwnd); */
|
|
|
|
(int)SendMessageA(hdr->hwndFrom, PSM_HWNDTOINDEX, (WPARAM)hwnd, 0);
|
2009-08-18 14:49:21 +02:00
|
|
|
return TRUE;
|
2009-08-14 00:36:56 +02:00
|
|
|
case PSN_KILLACTIVE:
|
|
|
|
/* prevent navigation away from the fourth page */
|
|
|
|
if(active_page == 3){
|
2013-11-04 17:47:32 +01:00
|
|
|
SetWindowLongPtrA(hwnd, DWLP_MSGRESULT, TRUE);
|
2009-08-14 00:36:56 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-08-18 14:49:21 +02:00
|
|
|
return FALSE;
|
2009-08-14 00:36:56 +02:00
|
|
|
}
|
|
|
|
|
2014-10-28 16:01:18 +01:00
|
|
|
static WNDPROC old_nav_dialog_proc;
|
|
|
|
|
|
|
|
static LRESULT CALLBACK new_nav_dialog_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case DM_SETDEFID:
|
|
|
|
ok( IsWindowEnabled( GetDlgItem(hwnd, wp) ), "button is not enabled\n" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return CallWindowProcW( old_nav_dialog_proc, hwnd, msg, wp, lp );
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK hook_proc( int code, WPARAM wp, LPARAM lp )
|
|
|
|
{
|
|
|
|
static BOOL done;
|
|
|
|
if (code == HCBT_CREATEWND)
|
|
|
|
{
|
|
|
|
CBT_CREATEWNDW *c = (CBT_CREATEWNDW *)lp;
|
|
|
|
|
|
|
|
/* The first dialog created will be the parent dialog */
|
2015-10-13 00:31:43 +02:00
|
|
|
if (!done && c->lpcs->lpszClass == (LPWSTR)WC_DIALOG)
|
2014-10-28 16:01:18 +01:00
|
|
|
{
|
|
|
|
old_nav_dialog_proc = (WNDPROC)SetWindowLongPtrW( (HWND)wp, GWLP_WNDPROC, (LONG_PTR)new_nav_dialog_proc );
|
|
|
|
done = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CallNextHookEx( NULL, code, wp, lp );
|
|
|
|
}
|
|
|
|
|
2009-08-14 00:36:56 +02:00
|
|
|
static void test_wiznavigation(void)
|
|
|
|
{
|
|
|
|
HPROPSHEETPAGE hpsp[4];
|
|
|
|
PROPSHEETPAGEA psp[4];
|
|
|
|
PROPSHEETHEADERA psh;
|
|
|
|
HWND hdlg, control;
|
|
|
|
LONG_PTR controlID;
|
2011-09-08 00:33:29 +02:00
|
|
|
DWORD style;
|
2009-08-14 00:36:56 +02:00
|
|
|
LRESULT defidres;
|
2009-08-18 14:49:21 +02:00
|
|
|
BOOL hwndtoindex_supported = TRUE;
|
2009-08-14 00:36:56 +02:00
|
|
|
const INT nextID = 12324;
|
|
|
|
const INT backID = 12323;
|
2014-10-28 16:01:18 +01:00
|
|
|
HHOOK hook;
|
|
|
|
|
|
|
|
/* set up a hook proc in order to subclass the main dialog early on */
|
|
|
|
hook = SetWindowsHookExW( WH_CBT, hook_proc, NULL, GetCurrentThreadId() );
|
2009-08-14 00:36:56 +02:00
|
|
|
|
|
|
|
/* create the property sheet pages */
|
|
|
|
memset(psp, 0, sizeof(PROPSHEETPAGEA) * 4);
|
|
|
|
|
|
|
|
psp[0].dwSize = sizeof(PROPSHEETPAGEA);
|
2009-10-28 14:57:22 +01:00
|
|
|
psp[0].hInstance = GetModuleHandleA(NULL);
|
2013-11-04 17:47:32 +01:00
|
|
|
U(psp[0]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_INTRO);
|
2009-08-14 00:36:56 +02:00
|
|
|
psp[0].pfnDlgProc = nav_page_proc;
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[0] = pCreatePropertySheetPageA(&psp[0]);
|
2009-08-14 00:36:56 +02:00
|
|
|
|
|
|
|
psp[1].dwSize = sizeof(PROPSHEETPAGEA);
|
2009-10-28 14:57:22 +01:00
|
|
|
psp[1].hInstance = GetModuleHandleA(NULL);
|
2013-11-04 17:47:32 +01:00
|
|
|
U(psp[1]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_EDIT);
|
2009-08-14 00:36:56 +02:00
|
|
|
psp[1].pfnDlgProc = nav_page_proc;
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[1] = pCreatePropertySheetPageA(&psp[1]);
|
2009-08-14 00:36:56 +02:00
|
|
|
|
|
|
|
psp[2].dwSize = sizeof(PROPSHEETPAGEA);
|
2009-10-28 14:57:22 +01:00
|
|
|
psp[2].hInstance = GetModuleHandleA(NULL);
|
2013-11-04 17:47:32 +01:00
|
|
|
U(psp[2]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_RADIO);
|
2009-08-14 00:36:56 +02:00
|
|
|
psp[2].pfnDlgProc = nav_page_proc;
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[2] = pCreatePropertySheetPageA(&psp[2]);
|
2009-08-14 00:36:56 +02:00
|
|
|
|
|
|
|
psp[3].dwSize = sizeof(PROPSHEETPAGEA);
|
2009-10-28 14:57:22 +01:00
|
|
|
psp[3].hInstance = GetModuleHandleA(NULL);
|
2013-11-04 17:47:32 +01:00
|
|
|
U(psp[3]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_EXIT);
|
2009-08-14 00:36:56 +02:00
|
|
|
psp[3].pfnDlgProc = nav_page_proc;
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[3] = pCreatePropertySheetPageA(&psp[3]);
|
2009-08-14 00:36:56 +02:00
|
|
|
|
|
|
|
/* set up the property sheet dialog */
|
|
|
|
memset(&psh, 0, sizeof(psh));
|
2011-09-06 00:21:04 +02:00
|
|
|
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
|
2009-08-14 00:36:56 +02:00
|
|
|
psh.dwFlags = PSH_MODELESS | PSH_WIZARD;
|
|
|
|
psh.pszCaption = "A Wizard";
|
|
|
|
psh.nPages = 4;
|
|
|
|
psh.hwndParent = GetDesktopWindow();
|
|
|
|
U3(psh).phpage = hpsp;
|
2018-01-24 13:47:09 +01:00
|
|
|
hdlg = (HWND)pPropertySheetA(&psh);
|
2011-07-06 11:49:14 +02:00
|
|
|
ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle %p\n", hdlg);
|
2009-08-14 00:36:56 +02:00
|
|
|
|
|
|
|
ok(active_page == 0, "Active page should be 0. Is: %d\n", active_page);
|
|
|
|
|
2013-11-04 17:47:32 +01:00
|
|
|
style = GetWindowLongA(hdlg, GWL_STYLE) & ~(DS_CONTEXTHELP|WS_SYSMENU);
|
2011-09-08 00:33:29 +02:00
|
|
|
ok(style == (WS_POPUP|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CAPTION|
|
|
|
|
DS_MODALFRAME|DS_SETFONT|DS_3DLOOK),
|
|
|
|
"got unexpected style: %x\n", style);
|
|
|
|
|
2009-08-14 00:36:56 +02:00
|
|
|
control = GetFocus();
|
2013-11-04 17:47:32 +01:00
|
|
|
controlID = GetWindowLongPtrA(control, GWLP_ID);
|
2009-08-14 00:36:56 +02:00
|
|
|
ok(controlID == nextID, "Focus should have been set to the Next button. Expected: %d, Found: %ld\n", nextID, controlID);
|
|
|
|
|
|
|
|
/* simulate pressing the Next button */
|
2013-11-04 17:47:32 +01:00
|
|
|
SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0);
|
2009-08-18 14:49:21 +02:00
|
|
|
if (!active_page) hwndtoindex_supported = FALSE;
|
|
|
|
if (hwndtoindex_supported)
|
|
|
|
ok(active_page == 1, "Active page should be 1 after pressing Next. Is: %d\n", active_page);
|
2009-08-14 00:36:56 +02:00
|
|
|
|
|
|
|
control = GetFocus();
|
2013-11-04 17:47:32 +01:00
|
|
|
controlID = GetWindowLongPtrA(control, GWLP_ID);
|
2009-08-14 00:36:56 +02:00
|
|
|
ok(controlID == IDC_PS_EDIT1, "Focus should be set to the first item on the second page. Expected: %d, Found: %ld\n", IDC_PS_EDIT1, controlID);
|
|
|
|
|
2013-11-04 17:47:32 +01:00
|
|
|
defidres = SendMessageA(hdlg, DM_GETDEFID, 0, 0);
|
2009-08-14 00:36:56 +02:00
|
|
|
ok(defidres == MAKELRESULT(nextID, DC_HASDEFID), "Expected default button ID to be %d, is %d\n", nextID, LOWORD(defidres));
|
|
|
|
|
|
|
|
/* set the focus to the second edit box on this page */
|
|
|
|
SetFocus(GetNextDlgTabItem(hdlg, control, FALSE));
|
|
|
|
|
|
|
|
/* press next again */
|
2013-11-04 17:47:32 +01:00
|
|
|
SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0);
|
2009-08-18 14:49:21 +02:00
|
|
|
if (hwndtoindex_supported)
|
|
|
|
ok(active_page == 2, "Active page should be 2 after pressing Next. Is: %d\n", active_page);
|
2009-08-14 00:36:56 +02:00
|
|
|
|
|
|
|
control = GetFocus();
|
2013-11-04 17:47:32 +01:00
|
|
|
controlID = GetWindowLongPtrA(control, GWLP_ID);
|
2009-08-14 00:36:56 +02:00
|
|
|
ok(controlID == IDC_PS_RADIO1, "Focus should have been set to item on third page. Expected: %d, Found %ld\n", IDC_PS_RADIO1, controlID);
|
|
|
|
|
|
|
|
/* back button */
|
2013-11-04 17:47:32 +01:00
|
|
|
SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_BACK, 0);
|
2009-08-18 14:49:21 +02:00
|
|
|
if (hwndtoindex_supported)
|
|
|
|
ok(active_page == 1, "Active page should be 1 after pressing Back. Is: %d\n", active_page);
|
2009-08-14 00:36:56 +02:00
|
|
|
|
|
|
|
control = GetFocus();
|
2013-11-04 17:47:32 +01:00
|
|
|
controlID = GetWindowLongPtrA(control, GWLP_ID);
|
2009-08-14 00:36:56 +02:00
|
|
|
ok(controlID == IDC_PS_EDIT1, "Focus should have been set to the first item on second page. Expected: %d, Found %ld\n", IDC_PS_EDIT1, controlID);
|
|
|
|
|
2013-11-04 17:47:32 +01:00
|
|
|
defidres = SendMessageA(hdlg, DM_GETDEFID, 0, 0);
|
2009-08-14 00:36:56 +02:00
|
|
|
ok(defidres == MAKELRESULT(backID, DC_HASDEFID), "Expected default button ID to be %d, is %d\n", backID, LOWORD(defidres));
|
|
|
|
|
|
|
|
/* press next twice */
|
2013-11-04 17:47:32 +01:00
|
|
|
SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0);
|
2009-08-18 14:49:21 +02:00
|
|
|
if (hwndtoindex_supported)
|
|
|
|
ok(active_page == 2, "Active page should be 2 after pressing Next. Is: %d\n", active_page);
|
2013-11-04 17:47:32 +01:00
|
|
|
SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0);
|
2009-08-18 14:49:21 +02:00
|
|
|
if (hwndtoindex_supported)
|
|
|
|
ok(active_page == 3, "Active page should be 3 after pressing Next. Is: %d\n", active_page);
|
|
|
|
else
|
|
|
|
active_page = 3;
|
2009-08-14 00:36:56 +02:00
|
|
|
|
|
|
|
control = GetFocus();
|
2013-11-04 17:47:32 +01:00
|
|
|
controlID = GetWindowLongPtrA(control, GWLP_ID);
|
2009-08-14 00:36:56 +02:00
|
|
|
ok(controlID == nextID, "Focus should have been set to the Next button. Expected: %d, Found: %ld\n", nextID, controlID);
|
|
|
|
|
|
|
|
/* try to navigate away, but shouldn't be able to */
|
2013-11-04 17:47:32 +01:00
|
|
|
SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_BACK, 0);
|
2009-08-14 00:36:56 +02:00
|
|
|
ok(active_page == 3, "Active page should still be 3 after pressing Back. Is: %d\n", active_page);
|
|
|
|
|
2013-11-04 17:47:32 +01:00
|
|
|
defidres = SendMessageA(hdlg, DM_GETDEFID, 0, 0);
|
2009-08-14 00:36:56 +02:00
|
|
|
ok(defidres == MAKELRESULT(nextID, DC_HASDEFID), "Expected default button ID to be %d, is %d\n", nextID, LOWORD(defidres));
|
|
|
|
|
|
|
|
DestroyWindow(hdlg);
|
2014-10-28 16:01:18 +01:00
|
|
|
UnhookWindowsHookEx( hook );
|
2009-08-14 00:36:56 +02:00
|
|
|
}
|
2010-05-29 23:12:06 +02:00
|
|
|
|
2009-08-31 14:09:00 +02:00
|
|
|
static void test_buttons(void)
|
|
|
|
{
|
|
|
|
HPROPSHEETPAGE hpsp[1];
|
|
|
|
PROPSHEETPAGEA psp;
|
|
|
|
PROPSHEETHEADERA psh;
|
|
|
|
HWND hdlg;
|
|
|
|
HWND button;
|
|
|
|
RECT rc;
|
|
|
|
int prevRight, top;
|
|
|
|
|
|
|
|
memset(&psp, 0, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = 0;
|
2009-10-28 14:57:22 +01:00
|
|
|
psp.hInstance = GetModuleHandleA(NULL);
|
2009-08-31 14:09:00 +02:00
|
|
|
U(psp).pszTemplate = "prop_page1";
|
|
|
|
U2(psp).pszIcon = NULL;
|
|
|
|
psp.pfnDlgProc = page_dlg_proc;
|
|
|
|
psp.lParam = 0;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[0] = pCreatePropertySheetPageA(&psp);
|
2009-08-31 14:09:00 +02:00
|
|
|
|
|
|
|
memset(&psh, 0, sizeof(psh));
|
2011-09-06 00:21:04 +02:00
|
|
|
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
|
2009-08-31 14:09:00 +02:00
|
|
|
psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK;
|
|
|
|
psh.pszCaption = "test caption";
|
|
|
|
psh.nPages = 1;
|
|
|
|
psh.hwndParent = GetDesktopWindow();
|
|
|
|
U3(psh).phpage = hpsp;
|
|
|
|
psh.pfnCallback = sheet_callback;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hdlg = (HWND)pPropertySheetA(&psh);
|
2011-07-06 11:49:14 +02:00
|
|
|
ok(hdlg != INVALID_HANDLE_VALUE, "got null handle\n");
|
2009-08-31 14:09:00 +02:00
|
|
|
|
|
|
|
/* OK button */
|
|
|
|
button = GetDlgItem(hdlg, IDOK);
|
|
|
|
GetWindowRect(button, &rc);
|
|
|
|
prevRight = rc.right;
|
|
|
|
top = rc.top;
|
|
|
|
|
|
|
|
/* Cancel button */
|
|
|
|
button = GetDlgItem(hdlg, IDCANCEL);
|
|
|
|
GetWindowRect(button, &rc);
|
|
|
|
ok(rc.top == top, "Cancel button should have same top as OK button\n");
|
2017-11-21 06:54:35 +01:00
|
|
|
if (rtl)
|
|
|
|
ok(rc.left < prevRight, "Cancel button should be to the left of OK button\n");
|
|
|
|
else
|
|
|
|
ok(rc.left > prevRight, "Cancel button should be to the right of OK button\n");
|
2009-08-31 14:09:00 +02:00
|
|
|
prevRight = rc.right;
|
|
|
|
|
|
|
|
button = GetDlgItem(hdlg, IDC_APPLY_BUTTON);
|
|
|
|
GetWindowRect(button, &rc);
|
|
|
|
ok(rc.top == top, "Apply button should have same top as OK button\n");
|
2017-11-21 06:54:35 +01:00
|
|
|
if (rtl)
|
|
|
|
ok(rc.left < prevRight, "Apply button should be to the left of Cancel button\n");
|
|
|
|
else
|
|
|
|
ok(rc.left > prevRight, "Apply button should be to the right of Cancel button\n");
|
2009-08-31 14:09:00 +02:00
|
|
|
prevRight = rc.right;
|
|
|
|
|
|
|
|
button = GetDlgItem(hdlg, IDHELP);
|
|
|
|
GetWindowRect(button, &rc);
|
|
|
|
ok(rc.top == top, "Help button should have same top as OK button\n");
|
2017-11-21 06:54:35 +01:00
|
|
|
if (rtl)
|
|
|
|
ok(rc.left < prevRight, "Help button should be to the left of Apply button\n");
|
|
|
|
else
|
|
|
|
ok(rc.left > prevRight, "Help button should be to the right of Apply button\n");
|
2009-08-31 14:09:00 +02:00
|
|
|
|
|
|
|
DestroyWindow(hdlg);
|
|
|
|
}
|
2009-08-14 00:36:56 +02:00
|
|
|
|
2010-05-29 23:12:06 +02:00
|
|
|
static BOOL add_button_has_been_pressed;
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK
|
|
|
|
page_with_custom_default_button_dlg_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch(LOWORD(wparam))
|
|
|
|
{
|
|
|
|
case IDC_PS_PUSHBUTTON1:
|
|
|
|
switch(HIWORD(wparam))
|
|
|
|
{
|
|
|
|
case BN_CLICKED:
|
|
|
|
add_button_has_been_pressed = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_custom_default_button(void)
|
|
|
|
{
|
2014-10-31 12:55:18 +01:00
|
|
|
HWND hdlg, page;
|
2010-05-29 23:12:06 +02:00
|
|
|
PROPSHEETPAGEA psp[1];
|
|
|
|
PROPSHEETHEADERA psh;
|
|
|
|
MSG msg;
|
|
|
|
LRESULT result;
|
|
|
|
|
|
|
|
psp[0].dwSize = sizeof (PROPSHEETPAGEA);
|
|
|
|
psp[0].dwFlags = PSP_USETITLE;
|
|
|
|
psp[0].hInstance = GetModuleHandleA(NULL);
|
2013-11-04 17:47:32 +01:00
|
|
|
U(psp[0]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_WITH_CUSTOM_DEFAULT_BUTTON);
|
2010-05-29 23:12:06 +02:00
|
|
|
U2(psp[0]).pszIcon = NULL;
|
|
|
|
psp[0].pfnDlgProc = page_with_custom_default_button_dlg_proc;
|
|
|
|
psp[0].pszTitle = "Page1";
|
|
|
|
psp[0].lParam = 0;
|
|
|
|
|
2011-09-06 00:21:04 +02:00
|
|
|
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
|
2010-05-29 23:12:06 +02:00
|
|
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_MODELESS;
|
|
|
|
psh.hwndParent = GetDesktopWindow();
|
|
|
|
psh.hInstance = GetModuleHandleA(NULL);
|
|
|
|
U(psh).pszIcon = NULL;
|
|
|
|
psh.pszCaption = "PropertySheet1";
|
|
|
|
psh.nPages = 1;
|
|
|
|
U3(psh).ppsp = psp;
|
|
|
|
U2(psh).nStartPage = 0;
|
|
|
|
|
|
|
|
/* The goal of the test is to make sure that the Add button is pressed
|
|
|
|
* when the ENTER key is pressed and a different control, a combobox,
|
|
|
|
* has the keyboard focus. */
|
|
|
|
add_button_has_been_pressed = FALSE;
|
|
|
|
|
|
|
|
/* Create the modeless property sheet. */
|
2018-01-24 13:47:09 +01:00
|
|
|
hdlg = (HWND)pPropertySheetA(&psh);
|
2010-05-29 23:12:06 +02:00
|
|
|
ok(hdlg != INVALID_HANDLE_VALUE, "Cannot create the property sheet\n");
|
|
|
|
|
|
|
|
/* Set the Add button as the default button. */
|
2013-11-04 17:47:32 +01:00
|
|
|
SendMessageA(hdlg, DM_SETDEFID, (WPARAM)IDC_PS_PUSHBUTTON1, 0);
|
2010-05-29 23:12:06 +02:00
|
|
|
|
|
|
|
/* Make sure the default button is the Add button. */
|
2013-11-04 17:47:32 +01:00
|
|
|
result = SendMessageA(hdlg, DM_GETDEFID, 0, 0);
|
2010-05-29 23:12:06 +02:00
|
|
|
ok(DC_HASDEFID == HIWORD(result), "The property sheet does not have a default button\n");
|
|
|
|
ok(IDC_PS_PUSHBUTTON1 == LOWORD(result), "The default button is not the Add button\n");
|
|
|
|
|
|
|
|
/* At this point, the combobox should have keyboard focus, so we press ENTER.
|
|
|
|
* Pull the lever, Kronk! */
|
2014-10-31 12:55:18 +01:00
|
|
|
page = (HWND)SendMessageW(hdlg, PSM_GETCURRENTPAGEHWND, 0, 0);
|
|
|
|
PostMessageW(GetDlgItem(page, IDC_PS_COMBO1), WM_KEYDOWN, VK_RETURN, 0);
|
2010-05-29 23:12:06 +02:00
|
|
|
|
|
|
|
/* Process all the messages in the queue for this thread. */
|
2013-11-04 17:47:32 +01:00
|
|
|
while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
|
2010-05-29 23:12:06 +02:00
|
|
|
{
|
2013-11-04 17:47:32 +01:00
|
|
|
/* (!PropSheet_IsDialogMessage(hdlg, &msg)) */
|
|
|
|
if (!((BOOL)SendMessageA(hdlg, PSM_ISDIALOGMESSAGE, 0, (LPARAM)&msg)))
|
2010-05-29 23:12:06 +02:00
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
2013-11-04 17:47:32 +01:00
|
|
|
DispatchMessageA(&msg);
|
2010-05-29 23:12:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(add_button_has_been_pressed, "The Add button has not been pressed!\n");
|
|
|
|
|
|
|
|
DestroyWindow(hdlg);
|
|
|
|
}
|
|
|
|
|
2010-11-06 09:54:12 +01:00
|
|
|
#define RECEIVER_SHEET_CALLBACK 0
|
|
|
|
#define RECEIVER_SHEET_WINPROC 1
|
|
|
|
#define RECEIVER_PAGE 2
|
|
|
|
|
|
|
|
#define NUM_MSG_SEQUENCES 1
|
|
|
|
#define PROPSHEET_SEQ_INDEX 0
|
|
|
|
|
|
|
|
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
|
|
|
|
static WNDPROC oldWndProc;
|
|
|
|
|
|
|
|
static const struct message property_sheet_seq[] = {
|
|
|
|
{ PSCB_PRECREATE, sent|id, 0, 0, RECEIVER_SHEET_CALLBACK },
|
|
|
|
{ PSCB_INITIALIZED, sent|id, 0, 0, RECEIVER_SHEET_CALLBACK },
|
|
|
|
{ WM_WINDOWPOSCHANGING, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
/*{ WM_NCCALCSIZE, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
|
|
|
{ WM_WINDOWPOSCHANGED, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_MOVE, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_SIZE, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
/*{ WM_GETTEXT, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_NCCALCSIZE, sent|id|optional, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ DM_REPOSITION, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
|
|
|
{ WM_WINDOWPOSCHANGING, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_WINDOWPOSCHANGING, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_ACTIVATEAPP, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
/*{ WM_NCACTIVATE, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETTEXT, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETTEXT, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
|
|
|
{ WM_ACTIVATE, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
/*{ WM_IME_SETCONTEXT, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_IME_NOTIFY, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
|
|
|
{ WM_SETFOCUS, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_KILLFOCUS, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
/*{ WM_IME_SETCONTEXT, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
|
|
|
{ WM_PARENTNOTIFY, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_INITDIALOG, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_WINDOWPOSCHANGING, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
/*{ WM_NCCALCSIZE, sent|id, 0, 0, RECEIVER_PAGE },*/
|
|
|
|
{ WM_CHILDACTIVATE, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_WINDOWPOSCHANGED, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_MOVE, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_SIZE, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_NOTIFY, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_STYLECHANGING, sent|id|optional, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_STYLECHANGED, sent|id|optional, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
/*{ WM_GETTEXT, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
|
|
|
{ WM_SETTEXT, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_SHOWWINDOW, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
/*{ 0x00000401, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ 0x00000400, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
|
|
|
{ WM_CHANGEUISTATE, sent|id|optional, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_UPDATEUISTATE, sent|id|optional, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_UPDATEUISTATE, sent|id|optional, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_SHOWWINDOW, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_WINDOWPOSCHANGING, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
/*{ WM_NCPAINT, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_ERASEBKGND, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
|
|
|
{ WM_CTLCOLORDLG, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_WINDOWPOSCHANGED, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
/*{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_PAINT, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_PAINT, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_NCPAINT, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_ERASEBKGND, sent|id, 0, 0, RECEIVER_PAGE },*/
|
|
|
|
{ WM_CTLCOLORDLG, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_CTLCOLORSTATIC, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_CTLCOLORSTATIC, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_CTLCOLORBTN, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_CTLCOLORBTN, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_CTLCOLORBTN, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
/*{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
|
|
|
{ WM_COMMAND, sent|id|optional, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_NOTIFY, sent|id|optional, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_NOTIFY, sent|id|optional, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_WINDOWPOSCHANGING, sent|id|optional, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_WINDOWPOSCHANGED, sent|id|optional, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
/*{ WM_NCACTIVATE, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_GETICON, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
2010-11-20 17:42:38 +01:00
|
|
|
/*{ WM_ACTIVATE, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
2010-11-06 09:54:12 +01:00
|
|
|
{ WM_ACTIVATE, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_ACTIVATEAPP, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
|
|
|
{ WM_ACTIVATEAPP, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_DESTROY, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },
|
2010-11-20 17:42:38 +01:00
|
|
|
{ WM_DESTROY, sent|id, 0, 0, RECEIVER_PAGE },*/
|
2010-11-06 09:54:12 +01:00
|
|
|
/*{ WM_NCDESTROY, sent|id, 0, 0, RECEIVER_PAGE },
|
|
|
|
{ WM_NCDESTROY, sent|id, 0, 0, RECEIVER_SHEET_WINPROC },*/
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void save_message(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, INT receiver)
|
|
|
|
{
|
2017-03-29 10:11:39 +02:00
|
|
|
struct message msg = { 0 };
|
2010-11-06 09:54:12 +01:00
|
|
|
|
|
|
|
if (message < WM_USER &&
|
|
|
|
message != WM_GETICON &&
|
|
|
|
message != WM_GETTEXT &&
|
|
|
|
message != WM_IME_SETCONTEXT &&
|
|
|
|
message != WM_IME_NOTIFY &&
|
|
|
|
message != WM_PAINT &&
|
|
|
|
message != WM_ERASEBKGND &&
|
|
|
|
message != WM_SETCURSOR &&
|
|
|
|
(message < WM_NCCREATE || message > WM_NCMBUTTONDBLCLK) &&
|
|
|
|
(message < WM_MOUSEFIRST || message > WM_MOUSEHWHEEL) &&
|
|
|
|
message != 0x90)
|
|
|
|
{
|
|
|
|
msg.message = message;
|
|
|
|
msg.flags = sent|wparam|lparam|id;
|
|
|
|
msg.wParam = wParam;
|
|
|
|
msg.lParam = lParam;
|
|
|
|
msg.id = receiver;
|
|
|
|
add_message(sequences, PROPSHEET_SEQ_INDEX, &msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK sheet_callback_messages_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
save_message(hwnd, msg, wParam, lParam, RECEIVER_SHEET_WINPROC);
|
|
|
|
|
2013-11-04 17:47:32 +01:00
|
|
|
return CallWindowProcA(oldWndProc, hwnd, msg, wParam, lParam);
|
2010-11-06 09:54:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int CALLBACK sheet_callback_messages(HWND hwnd, UINT msg, LPARAM lParam)
|
|
|
|
{
|
2011-07-19 15:25:35 +02:00
|
|
|
save_message(hwnd, msg, 0, lParam, RECEIVER_SHEET_CALLBACK);
|
2010-11-06 09:54:12 +01:00
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case PSCB_INITIALIZED:
|
2013-11-04 17:47:32 +01:00
|
|
|
oldWndProc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
|
|
|
|
SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)&sheet_callback_messages_proc);
|
2010-11-06 09:54:12 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK page_dlg_proc_messages(HWND hwnd, UINT msg, WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
save_message(hwnd, msg, wParam, lParam, RECEIVER_PAGE);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_messages(void)
|
|
|
|
{
|
|
|
|
HPROPSHEETPAGE hpsp[1];
|
|
|
|
PROPSHEETPAGEA psp;
|
|
|
|
PROPSHEETHEADERA psh;
|
|
|
|
HWND hdlg;
|
|
|
|
|
|
|
|
init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
memset(&psp, 0, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = 0;
|
|
|
|
psp.hInstance = GetModuleHandleA(NULL);
|
2013-11-04 17:47:32 +01:00
|
|
|
U(psp).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_MESSAGE_TEST);
|
2010-11-06 09:54:12 +01:00
|
|
|
U2(psp).pszIcon = NULL;
|
|
|
|
psp.pfnDlgProc = page_dlg_proc_messages;
|
|
|
|
psp.lParam = 0;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[0] = pCreatePropertySheetPageA(&psp);
|
2010-11-06 09:54:12 +01:00
|
|
|
|
|
|
|
memset(&psh, 0, sizeof(psh));
|
2011-09-06 00:21:04 +02:00
|
|
|
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
|
2010-11-06 09:54:12 +01:00
|
|
|
psh.dwFlags = PSH_NOAPPLYNOW | PSH_WIZARD | PSH_USECALLBACK
|
2010-11-20 17:42:38 +01:00
|
|
|
| PSH_MODELESS | PSH_USEICONID;
|
2010-11-06 09:54:12 +01:00
|
|
|
psh.pszCaption = "test caption";
|
|
|
|
psh.nPages = 1;
|
|
|
|
psh.hwndParent = GetDesktopWindow();
|
|
|
|
U3(psh).phpage = hpsp;
|
|
|
|
psh.pfnCallback = sheet_callback_messages;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hdlg = (HWND)pPropertySheetA(&psh);
|
2011-07-06 11:49:14 +02:00
|
|
|
ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle %p\n", hdlg);
|
|
|
|
|
2010-11-06 09:54:12 +01:00
|
|
|
ShowWindow(hdlg,SW_NORMAL);
|
|
|
|
|
|
|
|
ok_sequence(sequences, PROPSHEET_SEQ_INDEX, property_sheet_seq, "property sheet with custom window proc", TRUE);
|
|
|
|
|
|
|
|
DestroyWindow(hdlg);
|
|
|
|
}
|
|
|
|
|
2011-07-06 11:49:14 +02:00
|
|
|
static void test_PSM_ADDPAGE(void)
|
|
|
|
{
|
2012-08-29 18:29:47 +02:00
|
|
|
HPROPSHEETPAGE hpsp[5];
|
2011-07-06 11:49:14 +02:00
|
|
|
PROPSHEETPAGEA psp;
|
|
|
|
PROPSHEETHEADERA psh;
|
|
|
|
HWND hdlg, tab;
|
|
|
|
BOOL ret;
|
|
|
|
DWORD r;
|
|
|
|
|
|
|
|
memset(&psp, 0, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = 0;
|
|
|
|
psp.hInstance = GetModuleHandleA(NULL);
|
2013-11-04 17:47:32 +01:00
|
|
|
U(psp).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_MESSAGE_TEST);
|
2011-07-06 11:49:14 +02:00
|
|
|
U2(psp).pszIcon = NULL;
|
|
|
|
psp.pfnDlgProc = page_dlg_proc_messages;
|
|
|
|
psp.lParam = 0;
|
|
|
|
|
2017-01-17 05:58:38 +01:00
|
|
|
/* multiple pages with the same data */
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[0] = pCreatePropertySheetPageA(&psp);
|
|
|
|
hpsp[1] = pCreatePropertySheetPageA(&psp);
|
|
|
|
hpsp[2] = pCreatePropertySheetPageA(&psp);
|
2011-07-06 11:49:14 +02:00
|
|
|
|
2013-11-04 17:47:32 +01:00
|
|
|
U(psp).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_ERROR);
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[3] = pCreatePropertySheetPageA(&psp);
|
2012-08-29 18:29:47 +02:00
|
|
|
|
|
|
|
psp.dwFlags = PSP_PREMATURE;
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[4] = pCreatePropertySheetPageA(&psp);
|
2012-08-29 18:29:47 +02:00
|
|
|
|
2011-07-06 11:49:14 +02:00
|
|
|
memset(&psh, 0, sizeof(psh));
|
2011-09-06 00:21:04 +02:00
|
|
|
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
|
2011-07-06 11:49:14 +02:00
|
|
|
psh.dwFlags = PSH_MODELESS;
|
|
|
|
psh.pszCaption = "test caption";
|
|
|
|
psh.nPages = 1;
|
|
|
|
psh.hwndParent = GetDesktopWindow();
|
|
|
|
U3(psh).phpage = hpsp;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hdlg = (HWND)pPropertySheetA(&psh);
|
2011-07-06 11:49:14 +02:00
|
|
|
ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle %p\n", hdlg);
|
|
|
|
|
|
|
|
/* add pages one by one */
|
|
|
|
ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[1]);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* try with null and invalid value */
|
|
|
|
ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, 0);
|
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
|
|
|
ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)INVALID_HANDLE_VALUE);
|
|
|
|
}
|
|
|
|
/* check item count */
|
|
|
|
tab = (HWND)SendMessageA(hdlg, PSM_GETTABCONTROL, 0, 0);
|
|
|
|
|
|
|
|
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
|
|
|
|
ok(r == 2, "got %d\n", r);
|
|
|
|
|
|
|
|
ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[2]);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
|
|
|
|
|
|
|
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
|
|
|
|
ok(r == 3, "got %d\n", r);
|
|
|
|
|
2012-08-29 18:29:47 +02:00
|
|
|
/* add property sheet page that can't be created */
|
|
|
|
ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[3]);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
|
|
|
|
|
|
|
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
|
|
|
|
ok(r == 4, "got %d\n", r);
|
|
|
|
|
|
|
|
/* select page that can't be created */
|
2012-12-21 18:06:45 +01:00
|
|
|
ret = SendMessageA(hdlg, PSM_SETCURSEL, 3, 1);
|
2012-08-29 18:29:47 +02:00
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
|
|
|
|
|
|
|
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
|
|
|
|
ok(r == 3, "got %d\n", r);
|
|
|
|
|
|
|
|
/* test PSP_PREMATURE flag with incorrect property sheet page */
|
|
|
|
ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[4]);
|
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
|
|
|
|
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
|
|
|
|
ok(r == 3, "got %d\n", r);
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
pDestroyPropertySheetPage(hpsp[4]);
|
2011-07-06 11:49:14 +02:00
|
|
|
DestroyWindow(hdlg);
|
|
|
|
}
|
|
|
|
|
2017-01-17 05:58:38 +01:00
|
|
|
static void test_PSM_INSERTPAGE(void)
|
|
|
|
{
|
|
|
|
HPROPSHEETPAGE hpsp[5];
|
|
|
|
PROPSHEETPAGEA psp;
|
|
|
|
PROPSHEETHEADERA psh;
|
|
|
|
HWND hdlg, tab;
|
|
|
|
BOOL ret;
|
|
|
|
DWORD r;
|
|
|
|
|
|
|
|
memset(&psp, 0, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = 0;
|
|
|
|
psp.hInstance = GetModuleHandleA(NULL);
|
|
|
|
U(psp).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_MESSAGE_TEST);
|
|
|
|
U2(psp).pszIcon = NULL;
|
|
|
|
psp.pfnDlgProc = page_dlg_proc_messages;
|
|
|
|
psp.lParam = 0;
|
|
|
|
|
|
|
|
/* multiple pages with the same data */
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[0] = pCreatePropertySheetPageA(&psp);
|
|
|
|
hpsp[1] = pCreatePropertySheetPageA(&psp);
|
|
|
|
hpsp[2] = pCreatePropertySheetPageA(&psp);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
U(psp).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_ERROR);
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[3] = pCreatePropertySheetPageA(&psp);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
psp.dwFlags = PSP_PREMATURE;
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp[4] = pCreatePropertySheetPageA(&psp);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
memset(&psh, 0, sizeof(psh));
|
|
|
|
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
|
|
|
|
psh.dwFlags = PSH_MODELESS;
|
|
|
|
psh.pszCaption = "test caption";
|
|
|
|
psh.nPages = 1;
|
|
|
|
psh.hwndParent = GetDesktopWindow();
|
|
|
|
U3(psh).phpage = hpsp;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
hdlg = (HWND)pPropertySheetA(&psh);
|
2017-01-17 05:58:38 +01:00
|
|
|
ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle %p\n", hdlg);
|
|
|
|
|
|
|
|
/* add pages one by one */
|
|
|
|
ret = SendMessageA(hdlg, PSM_INSERTPAGE, 5, (LPARAM)hpsp[1]);
|
2017-02-12 19:16:31 +01:00
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
/* try with invalid values */
|
|
|
|
ret = SendMessageA(hdlg, PSM_INSERTPAGE, 0, 0);
|
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
|
|
|
ret = SendMessageA(hdlg, PSM_INSERTPAGE, 0, (LPARAM)INVALID_HANDLE_VALUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = SendMessageA(hdlg, PSM_INSERTPAGE, (WPARAM)INVALID_HANDLE_VALUE, (LPARAM)hpsp[2]);
|
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* check item count */
|
|
|
|
tab = (HWND)SendMessageA(hdlg, PSM_GETTABCONTROL, 0, 0);
|
|
|
|
|
|
|
|
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
|
2017-02-12 19:16:31 +01:00
|
|
|
ok(r == 2, "got %d\n", r);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
ret = SendMessageA(hdlg, PSM_INSERTPAGE, (WPARAM)hpsp[1], (LPARAM)hpsp[2]);
|
2017-02-12 19:16:31 +01:00
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
|
2017-02-12 19:16:31 +01:00
|
|
|
ok(r == 3, "got %d\n", r);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
/* add property sheet page that can't be created */
|
|
|
|
ret = SendMessageA(hdlg, PSM_INSERTPAGE, 1, (LPARAM)hpsp[3]);
|
2017-02-12 19:16:31 +01:00
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
|
2017-02-12 19:16:31 +01:00
|
|
|
ok(r == 4, "got %d\n", r);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
/* select page that can't be created */
|
|
|
|
ret = SendMessageA(hdlg, PSM_SETCURSEL, 1, 0);
|
2017-02-12 19:16:31 +01:00
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
|
2017-02-12 19:16:31 +01:00
|
|
|
ok(r == 3, "got %d\n", r);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
|
|
|
/* test PSP_PREMATURE flag with incorrect property sheet page */
|
|
|
|
ret = SendMessageA(hdlg, PSM_INSERTPAGE, 0, (LPARAM)hpsp[4]);
|
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
|
|
|
|
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
|
2017-02-12 19:16:31 +01:00
|
|
|
ok(r == 3, "got %d\n", r);
|
2017-01-17 05:58:38 +01:00
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
pDestroyPropertySheetPage(hpsp[4]);
|
2017-01-17 05:58:38 +01:00
|
|
|
DestroyWindow(hdlg);
|
|
|
|
}
|
|
|
|
|
2017-02-19 20:26:27 +01:00
|
|
|
struct custom_proppage
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
PROPSHEETPAGEA pageA;
|
|
|
|
PROPSHEETPAGEW pageW;
|
|
|
|
} u;
|
|
|
|
unsigned int addref_called;
|
|
|
|
unsigned int release_called;
|
|
|
|
};
|
|
|
|
|
|
|
|
static UINT CALLBACK proppage_callback_a(HWND hwnd, UINT msg, PROPSHEETPAGEA *psp)
|
|
|
|
{
|
|
|
|
struct custom_proppage *cpage = (struct custom_proppage *)psp->lParam;
|
|
|
|
PROPSHEETPAGEA *psp_orig = &cpage->u.pageA;
|
|
|
|
|
|
|
|
ok(hwnd == NULL, "Expected NULL hwnd, got %p\n", hwnd);
|
|
|
|
|
|
|
|
ok(psp->lParam && psp->lParam != (LPARAM)psp, "Expected newly allocated page description, got %lx, %p\n",
|
|
|
|
psp->lParam, psp);
|
|
|
|
ok(psp_orig->pszTitle == psp->pszTitle, "Expected same page title pointer\n");
|
|
|
|
ok(!lstrcmpA(psp_orig->pszTitle, psp->pszTitle), "Expected same page title string\n");
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case PSPCB_ADDREF:
|
|
|
|
ok(psp->dwSize > PROPSHEETPAGEA_V1_SIZE, "Expected ADDREF for V2+ only, got size %u\n", psp->dwSize);
|
|
|
|
cpage->addref_called++;
|
|
|
|
break;
|
|
|
|
case PSPCB_RELEASE:
|
|
|
|
ok(psp->dwSize >= PROPSHEETPAGEA_V1_SIZE, "Unexpected RELEASE, got size %u\n", psp->dwSize);
|
|
|
|
cpage->release_called++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ok(0, "Unexpected message %u\n", msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT CALLBACK proppage_callback_w(HWND hwnd, UINT msg, PROPSHEETPAGEW *psp)
|
|
|
|
{
|
|
|
|
struct custom_proppage *cpage = (struct custom_proppage *)psp->lParam;
|
|
|
|
PROPSHEETPAGEW *psp_orig = &cpage->u.pageW;
|
|
|
|
|
|
|
|
ok(hwnd == NULL, "Expected NULL hwnd, got %p\n", hwnd);
|
|
|
|
ok(psp->lParam && psp->lParam != (LPARAM)psp, "Expected newly allocated page description, got %lx, %p\n",
|
|
|
|
psp->lParam, psp);
|
|
|
|
ok(psp_orig->pszTitle == psp->pszTitle, "Expected same page title pointer\n");
|
|
|
|
ok(!lstrcmpW(psp_orig->pszTitle, psp->pszTitle), "Expected same page title string\n");
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case PSPCB_ADDREF:
|
|
|
|
ok(psp->dwSize > PROPSHEETPAGEW_V1_SIZE, "Expected ADDREF for V2+ only, got size %u\n", psp->dwSize);
|
|
|
|
cpage->addref_called++;
|
|
|
|
break;
|
|
|
|
case PSPCB_RELEASE:
|
|
|
|
ok(psp->dwSize >= PROPSHEETPAGEW_V1_SIZE, "Unexpected RELEASE, got size %u\n", psp->dwSize);
|
|
|
|
cpage->release_called++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ok(0, "Unexpected message %u\n", msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_CreatePropertySheetPage(void)
|
|
|
|
{
|
|
|
|
struct custom_proppage page;
|
|
|
|
HPROPSHEETPAGE hpsp;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
memset(&page.u.pageA, 0, sizeof(page.u.pageA));
|
|
|
|
page.u.pageA.dwFlags = PSP_USECALLBACK;
|
|
|
|
page.u.pageA.pfnDlgProc = page_dlg_proc_messages;
|
|
|
|
page.u.pageA.pfnCallback = proppage_callback_a;
|
|
|
|
page.u.pageA.lParam = (LPARAM)&page;
|
|
|
|
page.u.pageA.pszTitle = "Title";
|
|
|
|
|
|
|
|
/* Only minimal size validation is performed */
|
|
|
|
for (page.u.pageA.dwSize = PROPSHEETPAGEA_V1_SIZE - 1; page.u.pageA.dwSize <= PROPSHEETPAGEA_V4_SIZE + 1; page.u.pageA.dwSize++)
|
|
|
|
{
|
|
|
|
page.addref_called = 0;
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp = pCreatePropertySheetPageA(&page.u.pageA);
|
2017-02-19 20:26:27 +01:00
|
|
|
|
|
|
|
if (page.u.pageA.dwSize < PROPSHEETPAGEA_V1_SIZE)
|
|
|
|
ok(hpsp == NULL, "Expected failure, size %u\n", page.u.pageA.dwSize);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(hpsp != NULL, "Failed to create a page, size %u\n", page.u.pageA.dwSize);
|
|
|
|
ok(page.addref_called == (page.u.pageA.dwSize > PROPSHEETPAGEA_V1_SIZE) ? 1 : 0, "Expected ADDREF callback message\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hpsp)
|
|
|
|
{
|
|
|
|
page.release_called = 0;
|
2018-01-24 13:47:09 +01:00
|
|
|
ret = pDestroyPropertySheetPage(hpsp);
|
2017-02-19 20:26:27 +01:00
|
|
|
ok(ret, "Failed to destroy a page\n");
|
|
|
|
ok(page.release_called == 1, "Expected RELEASE callback message\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&page.u.pageW, 0, sizeof(page.u.pageW));
|
|
|
|
page.u.pageW.dwFlags = PSP_USECALLBACK;
|
|
|
|
page.u.pageW.pfnDlgProc = page_dlg_proc_messages;
|
|
|
|
page.u.pageW.pfnCallback = proppage_callback_w;
|
|
|
|
page.u.pageW.lParam = (LPARAM)&page;
|
2020-09-25 09:36:17 +02:00
|
|
|
page.u.pageW.pszTitle = L"Title";
|
2017-02-19 20:26:27 +01:00
|
|
|
|
|
|
|
for (page.u.pageW.dwSize = PROPSHEETPAGEW_V1_SIZE - 1; page.u.pageW.dwSize <= PROPSHEETPAGEW_V4_SIZE + 1; page.u.pageW.dwSize++)
|
|
|
|
{
|
|
|
|
page.addref_called = 0;
|
2018-01-24 13:47:09 +01:00
|
|
|
hpsp = pCreatePropertySheetPageW(&page.u.pageW);
|
2017-02-19 20:26:27 +01:00
|
|
|
|
|
|
|
if (page.u.pageW.dwSize < PROPSHEETPAGEW_V1_SIZE)
|
|
|
|
ok(hpsp == NULL, "Expected failure, size %u\n", page.u.pageW.dwSize);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(hpsp != NULL, "Failed to create a page, size %u\n", page.u.pageW.dwSize);
|
|
|
|
ok(page.addref_called == (page.u.pageW.dwSize > PROPSHEETPAGEW_V1_SIZE) ? 1 : 0, "Expected ADDREF callback message\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hpsp)
|
|
|
|
{
|
|
|
|
page.release_called = 0;
|
2018-01-24 13:47:09 +01:00
|
|
|
ret = pDestroyPropertySheetPage(hpsp);
|
2017-02-19 20:26:27 +01:00
|
|
|
ok(ret, "Failed to destroy a page\n");
|
|
|
|
ok(page.release_called == 1, "Expected RELEASE callback message\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-18 16:45:42 +01:00
|
|
|
static void test_bad_control_class(void)
|
|
|
|
{
|
|
|
|
PROPSHEETPAGEA psp;
|
|
|
|
PROPSHEETHEADERA psh;
|
|
|
|
HPROPSHEETPAGE hpsp;
|
|
|
|
INT_PTR ret;
|
|
|
|
|
|
|
|
memset(&psp, 0, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.hInstance = GetModuleHandleA(NULL);
|
|
|
|
U(psp).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_BAD_CONTROL);
|
|
|
|
psp.pfnDlgProc = page_dlg_proc;
|
|
|
|
|
|
|
|
hpsp = pCreatePropertySheetPageA(&psp);
|
|
|
|
ok(hpsp != 0, "CreatePropertySheetPage failed\n");
|
|
|
|
|
|
|
|
memset(&psh, 0, sizeof(psh));
|
|
|
|
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
|
|
|
|
psh.nPages = 1;
|
|
|
|
psh.hwndParent = GetDesktopWindow();
|
|
|
|
U3(psh).phpage = &hpsp;
|
|
|
|
|
|
|
|
ret = pPropertySheetA(&psh);
|
|
|
|
ok(ret == 0, "got %ld\n", ret);
|
|
|
|
|
|
|
|
/* Need to recreate hpsp otherwise the test fails under Windows */
|
|
|
|
hpsp = pCreatePropertySheetPageA(&psp);
|
|
|
|
ok(hpsp != 0, "CreatePropertySheetPage failed\n");
|
|
|
|
U3(psh).phpage = &hpsp;
|
|
|
|
|
|
|
|
psh.dwFlags = PSH_MODELESS;
|
|
|
|
ret = pPropertySheetA(&psh);
|
|
|
|
ok(ret != 0, "got %ld\n", ret);
|
|
|
|
|
|
|
|
ok(IsWindow((HWND)ret), "bad window handle %#lx\n", ret);
|
|
|
|
DestroyWindow((HWND)ret);
|
|
|
|
}
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
static void init_functions(void)
|
|
|
|
{
|
|
|
|
HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
|
|
|
|
|
|
|
|
#define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
|
|
|
|
X(CreatePropertySheetPageA);
|
|
|
|
X(CreatePropertySheetPageW);
|
|
|
|
X(DestroyPropertySheetPage);
|
|
|
|
X(PropertySheetA);
|
|
|
|
#undef X
|
|
|
|
}
|
|
|
|
|
2006-04-06 17:55:32 +02:00
|
|
|
START_TEST(propsheet)
|
|
|
|
{
|
2017-11-21 06:54:35 +01:00
|
|
|
detect_locale();
|
|
|
|
if (rtl)
|
|
|
|
{
|
|
|
|
/* use locale-specific RTL resources when on an RTL locale */
|
|
|
|
/* without this, propsheets on RTL locales use English LTR resources */
|
|
|
|
trace("RTL locale detected\n");
|
|
|
|
SetProcessDefaultLayout(LAYOUT_RTL);
|
|
|
|
}
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
init_functions();
|
|
|
|
|
2018-12-18 16:45:42 +01:00
|
|
|
test_bad_control_class();
|
2006-04-06 17:55:32 +02:00
|
|
|
test_title();
|
2007-04-03 19:58:19 +02:00
|
|
|
test_nopage();
|
2008-07-08 20:52:57 +02:00
|
|
|
test_disableowner();
|
2009-08-14 00:36:56 +02:00
|
|
|
test_wiznavigation();
|
2009-08-31 14:09:00 +02:00
|
|
|
test_buttons();
|
2010-05-29 23:12:06 +02:00
|
|
|
test_custom_default_button();
|
2010-11-06 09:54:12 +01:00
|
|
|
test_messages();
|
2011-07-06 11:49:14 +02:00
|
|
|
test_PSM_ADDPAGE();
|
2017-01-17 05:58:38 +01:00
|
|
|
test_PSM_INSERTPAGE();
|
2017-02-19 20:26:27 +01:00
|
|
|
test_CreatePropertySheetPage();
|
2006-04-06 17:55:32 +02:00
|
|
|
}
|