1 /* Unit test suite for property sheet control.
3 * Copyright 2006 Huw Davies
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/test.h"
27 static int CALLBACK sheet_callback(HWND hwnd, UINT msg, LPARAM lparam)
31 case PSCB_INITIALIZED:
34 GetWindowTextA(hwnd, caption, sizeof(caption));
35 ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
42 static INT_PTR CALLBACK page_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
49 HWND sheet = GetParent(hwnd);
51 GetWindowTextA(sheet, caption, sizeof(caption));
52 ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
58 NMHDR *nmhdr = (NMHDR *)lparam;
72 static void test_title(void)
74 HPROPSHEETPAGE hpsp[1];
79 memset(&psp, 0, sizeof(psp));
80 psp.dwSize = sizeof(psp);
82 psp.hInstance = GetModuleHandleW(NULL);
83 U(psp).pszTemplate = "prop_page1";
84 U2(psp).pszIcon = NULL;
85 psp.pfnDlgProc = page_dlg_proc;
88 hpsp[0] = CreatePropertySheetPageA(&psp);
90 memset(&psh, 0, sizeof(psh));
91 psh.dwSize = sizeof(psh);
92 psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK;
93 psh.pszCaption = "test caption";
95 psh.hwndParent = GetDesktopWindow();
96 U3(psh).phpage = hpsp;
97 psh.pfnCallback = sheet_callback;
99 hdlg = (HWND)PropertySheetA(&psh);
103 static void test_nopage(void)
105 HPROPSHEETPAGE hpsp[1];
107 PROPSHEETHEADERA psh;
110 memset(&psp, 0, sizeof(psp));
111 psp.dwSize = sizeof(psp);
113 psp.hInstance = GetModuleHandleW(NULL);
114 U(psp).pszTemplate = "prop_page1";
115 U2(psp).pszIcon = NULL;
116 psp.pfnDlgProc = page_dlg_proc;
119 hpsp[0] = CreatePropertySheetPageA(&psp);
121 memset(&psh, 0, sizeof(psh));
122 psh.dwSize = sizeof(psh);
123 psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK;
124 psh.pszCaption = "test caption";
126 psh.hwndParent = GetDesktopWindow();
127 U3(psh).phpage = hpsp;
128 psh.pfnCallback = sheet_callback;
130 hdlg = (HWND)PropertySheetA(&psh);
131 ShowWindow(hdlg,SW_NORMAL);
132 SendMessage(hdlg, PSM_REMOVEPAGE, 0, 0);
133 RedrawWindow(hdlg,NULL,NULL,RDW_UPDATENOW|RDW_ERASENOW);
137 static int CALLBACK disableowner_callback(HWND hwnd, UINT msg, LPARAM lparam)
141 case PSCB_INITIALIZED:
143 ok(IsWindowEnabled(parent) == 0, "parent window should be disabled\n");
151 static void register_parent_wnd_class(void)
156 cls.lpfnWndProc = DefWindowProcA;
159 cls.hInstance = GetModuleHandleA(NULL);
161 cls.hCursor = LoadCursorA(0, IDC_ARROW);
162 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
163 cls.lpszMenuName = NULL;
164 cls.lpszClassName = "parent class";
165 RegisterClassA(&cls);
168 static void test_disableowner(void)
170 HPROPSHEETPAGE hpsp[1];
172 PROPSHEETHEADERA psh;
174 register_parent_wnd_class();
175 parent = CreateWindowA("parent class", "", WS_CAPTION | WS_SYSMENU | WS_VISIBLE, 100, 100, 100, 100, GetDesktopWindow(), NULL, GetModuleHandleA(NULL), 0);
177 memset(&psp, 0, sizeof(psp));
178 psp.dwSize = sizeof(psp);
180 psp.hInstance = GetModuleHandleW(NULL);
181 U(psp).pszTemplate = "prop_page1";
182 U2(psp).pszIcon = NULL;
183 psp.pfnDlgProc = NULL;
186 hpsp[0] = CreatePropertySheetPageA(&psp);
188 memset(&psh, 0, sizeof(psh));
189 psh.dwSize = sizeof(psh);
190 psh.dwFlags = PSH_USECALLBACK;
191 psh.pszCaption = "test caption";
193 psh.hwndParent = parent;
194 U3(psh).phpage = hpsp;
195 psh.pfnCallback = disableowner_callback;
197 PropertySheetA(&psh);
198 ok(IsWindowEnabled(parent) != 0, "parent window should be enabled\n");
199 DestroyWindow(parent);
202 START_TEST(propsheet)