comctl32: toolbar: Fix the return code of TB_ADDBITMAP.
[wine] / dlls / comctl32 / tests / 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 #define NONAMELESSUNION
21 #define NONAMELESSSTRUCT
22
23 #include <windows.h>
24 #include <commctrl.h>
25
26 #include "wine/test.h"
27
28 static int CALLBACK sheet_callback(HWND hwnd, UINT msg, LPARAM lparam)
29 {
30     switch(msg)
31     {
32     case PSCB_INITIALIZED:
33       {
34         char caption[256];
35         GetWindowTextA(hwnd, caption, sizeof(caption));
36         ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
37         return 0;
38       }
39     }
40     return 0;
41 }
42         
43 static INT_PTR CALLBACK page_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
44                                       LPARAM lparam)
45 {
46     switch(msg)
47     {
48     case WM_INITDIALOG:
49       {
50         HWND sheet = GetParent(hwnd);
51         char caption[256];
52         GetWindowTextA(sheet, caption, sizeof(caption));
53         ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
54         return TRUE;
55       }
56
57     case WM_NOTIFY:
58       {
59         NMHDR *nmhdr = (NMHDR *)lparam;
60         switch(nmhdr->code)
61         {
62         case PSN_APPLY:
63             return TRUE;
64         default:
65             return FALSE;
66         }
67       }
68     default:
69         return FALSE;
70     }
71 }
72
73 static void test_title(void)
74 {
75     HPROPSHEETPAGE hpsp[1];
76     PROPSHEETPAGEA psp;
77     PROPSHEETHEADERA psh;
78     HWND hdlg;
79
80     memset(&psp, 0, sizeof(psp));
81     psp.dwSize = sizeof(psp);
82     psp.dwFlags = 0;
83     psp.hInstance = GetModuleHandleW(NULL);
84     psp.u.pszTemplate = "prop_page1";
85     psp.u2.pszIcon = NULL;
86     psp.pfnDlgProc = page_dlg_proc;
87     psp.lParam = 0;
88
89     hpsp[0] = CreatePropertySheetPageA(&psp);
90
91     memset(&psh, 0, sizeof(psh));
92     psh.dwSize = sizeof(psh);
93     psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK;
94     psh.pszCaption = "test caption";
95     psh.nPages = 1;
96     psh.hwndParent = GetDesktopWindow();
97     psh.u3.phpage = hpsp;
98     psh.pfnCallback = sheet_callback;
99
100     hdlg = (HWND)PropertySheetA(&psh);
101     DestroyWindow(hdlg);
102 }
103
104 START_TEST(propsheet)
105 {
106     test_title();
107 }