Autosyncing with Wine HEAD
[reactos.git] / rostests / winetests / comctl32 / propsheet.c
1 /* Unit test suite for property sheet control.
2 *
3 * Copyright 2006 Huw Davies
4 *
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.
9 *
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.
14 *
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
18 */
19
20 #include <windows.h>
21 #include <commctrl.h>
22
23 #include "wine/test.h"
24
25 static int CALLBACK sheet_callback(HWND hwnd, UINT msg, LPARAM lparam)
26 {
27 switch(msg)
28 {
29 case PSCB_INITIALIZED:
30 {
31 char caption[256];
32 GetWindowTextA(hwnd, caption, sizeof(caption));
33 ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
34 return 0;
35 }
36 }
37 return 0;
38 }
39
40 static INT_PTR CALLBACK page_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
41 LPARAM lparam)
42 {
43 switch(msg)
44 {
45 case WM_INITDIALOG:
46 {
47 HWND sheet = GetParent(hwnd);
48 char caption[256];
49 GetWindowTextA(sheet, caption, sizeof(caption));
50 ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
51 return TRUE;
52 }
53
54 case WM_NOTIFY:
55 {
56 NMHDR *nmhdr = (NMHDR *)lparam;
57 switch(nmhdr->code)
58 {
59 case PSN_APPLY:
60 return TRUE;
61 default:
62 return FALSE;
63 }
64 }
65 default:
66 return FALSE;
67 }
68 }
69
70 static void test_title(void)
71 {
72 HPROPSHEETPAGE hpsp[1];
73 PROPSHEETPAGEA psp;
74 PROPSHEETHEADERA psh;
75 HWND hdlg;
76
77 memset(&psp, 0, sizeof(psp));
78 psp.dwSize = sizeof(psp);
79 psp.dwFlags = 0;
80 psp.hInstance = GetModuleHandleW(NULL);
81 U(psp).pszTemplate = "prop_page1";
82 U2(psp).pszIcon = NULL;
83 psp.pfnDlgProc = page_dlg_proc;
84 psp.lParam = 0;
85
86 hpsp[0] = CreatePropertySheetPageA(&psp);
87
88 memset(&psh, 0, sizeof(psh));
89 psh.dwSize = sizeof(psh);
90 psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK;
91 psh.pszCaption = "test caption";
92 psh.nPages = 1;
93 psh.hwndParent = GetDesktopWindow();
94 U3(psh).phpage = hpsp;
95 psh.pfnCallback = sheet_callback;
96
97 hdlg = (HWND)PropertySheetA(&psh);
98 DestroyWindow(hdlg);
99 }
100
101 static void test_nopage(void)
102 {
103 HPROPSHEETPAGE hpsp[1];
104 PROPSHEETPAGEA psp;
105 PROPSHEETHEADERA psh;
106 HWND hdlg;
107
108 memset(&psp, 0, sizeof(psp));
109 psp.dwSize = sizeof(psp);
110 psp.dwFlags = 0;
111 psp.hInstance = GetModuleHandleW(NULL);
112 U(psp).pszTemplate = "prop_page1";
113 U2(psp).pszIcon = NULL;
114 psp.pfnDlgProc = page_dlg_proc;
115 psp.lParam = 0;
116
117 hpsp[0] = CreatePropertySheetPageA(&psp);
118
119 memset(&psh, 0, sizeof(psh));
120 psh.dwSize = sizeof(psh);
121 psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK;
122 psh.pszCaption = "test caption";
123 psh.nPages = 1;
124 psh.hwndParent = GetDesktopWindow();
125 U3(psh).phpage = hpsp;
126 psh.pfnCallback = sheet_callback;
127
128 hdlg = (HWND)PropertySheetA(&psh);
129 ShowWindow(hdlg,SW_NORMAL);
130 SendMessage(hdlg, PSM_REMOVEPAGE, 0, 0);
131 RedrawWindow(hdlg,NULL,NULL,RDW_UPDATENOW|RDW_ERASENOW);
132 DestroyWindow(hdlg);
133 }
134
135 START_TEST(propsheet)
136 {
137 test_title();
138 test_nopage();
139 }