ReactOS  0.4.15-dev-1207-g698a8e6
propsheet.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Test for v6 property sheet
5  * COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6  */
7 
8 #include "wine/test.h"
9 #include <windows.h>
10 #include <windowsx.h>
11 #include <commctrl.h>
12 #include <prsht.h>
13 
14 #define IDC_APPLY_BUTTON 12321
15 
17 
19 {
21  SetDlgItemTextW(hwnd, edt1, L"text");
22  SetTimer(hwnd, 999, 300, NULL);
23  return TRUE;
24 }
25 
26 static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
27 {
28  switch (id)
29  {
30  case IDOK:
31  case IDCANCEL:
32  EndDialog(hwnd, id);
33  break;
34  case edt1:
35  if (codeNotify == EN_CHANGE)
36  {
37  s_bNotified = TRUE;
39  }
40  break;
41  }
42 }
43 
44 static void OnTimer(HWND hwnd, UINT id)
45 {
46  HWND hwndParent, hwndApply;
47 
48  KillTimer(hwnd, id);
49 
51 
54  ok_int(IsWindowEnabled(hwndApply), FALSE);
55 
57  ok_int(IsWindowEnabled(hwndApply), TRUE);
58 
60  ok_int(IsWindowEnabled(hwndApply), FALSE);
61 
63 }
64 
65 static INT_PTR CALLBACK
67 {
68  switch (uMsg)
69  {
73  }
74  return 0;
75 }
76 
77 #ifdef _MSC_VER
78 #define CHECK_STRUCT_SIZE(x, y) C_ASSERT((x) == (y))
79 #else
80 // Can't do this compile time, thanks gcc
81 // 'error: non-nested function with variably modified type'
82 #define CHECK_STRUCT_SIZE(x, y) ok((x) == (y), "Wrong size for %s, got %u, expected %u\n", #x, y, x)
83 #endif
84 
85 // Validate struct sizes
86 static void test_StructSizes()
87 {
88 #ifdef _M_X64
95 
102 #else
109 
116 #endif
117 }
118 
123 
124 // Show that the Apply button is not enabled by default
126 {
127  PROPSHEETPAGEW psp = {0};
128  PROPSHEETHEADERW header = {0};
129  HPROPSHEETPAGE hpsp[1];
130 
131  psp.dwSize = sizeof(psp);
132  psp.dwFlags = PSP_DEFAULT;
134  psp.pszTemplate = MAKEINTRESOURCEW(1);
135  psp.pfnDlgProc = Page1DlgProc;
136  hpsp[0] = pCreatePropertySheetPageW(&psp);
137  ok(hpsp[0] != NULL, "hpsp[0] was NULL.\n");
138 
139  header.dwSize = sizeof(header);
140  header.dwFlags = 0;
141  header.hInstance = GetModuleHandleW(NULL);
142  header.hwndParent = NULL;
143  header.nPages = ARRAYSIZE(hpsp);
144  header.phpage = hpsp;
145  header.pszCaption = L"propsheet";
146  ok(pPropertySheetW(&header) > 0, "PropertySheet returned non-positive value.\n");
147 }
148 
149 
150 START_TEST(propsheet)
151 {
152  HMODULE hComCtl32;
153 
154  hComCtl32 = LoadLibraryW(L"comctl32.dll");
155  pCreatePropertySheetPageW = (FN_CreatePropertySheetPageW)GetProcAddress(hComCtl32, "CreatePropertySheetPageW");
156  pPropertySheetW = (FN_PropertySheetW)GetProcAddress(hComCtl32, "PropertySheetW");
157 
158  ok(pCreatePropertySheetPageW != NULL, "pCreatePropertySheetPageW was NULL.\n");
159  ok(pPropertySheetW != NULL, "pPropertySheetW was NULL.\n");
160 
162  {
163  skip("!pCreatePropertySheetPageW || !pPropertySheetW\n");
164  return;
165  }
166 
169 
170  FreeLibrary(hComCtl32);
171 }
static void test_StructSizes()
Definition: propsheet.c:86
HPROPSHEETPAGE(WINAPI * FN_CreatePropertySheetPageW)(LPCPROPSHEETPAGEW)
Definition: propsheet.c:119
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
Definition: propsheet.c:18
#define IDOK
Definition: winuser.h:824
LPCWSTR pszTemplate
Definition: prsht.h:218
#define IDC_APPLY_BUTTON
Definition: propsheet.c:14
#define PROPSHEETHEADERW_V2_SIZE
Definition: prsht.h:326
#define TRUE
Definition: types.h:120
static BOOL s_bNotified
Definition: propsheet.c:16
#define PROPSHEETHEADERW_V1_SIZE
Definition: prsht.h:325
#define CALLBACK
Definition: compat.h:35
static FN_PropertySheetW pPropertySheetW
Definition: propsheet.c:122
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT_PTR
Definition: typedefs.h:64
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define PROPSHEETPAGEW_V4_SIZE
Definition: prsht.h:249
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
int(WINAPI * FN_PropertySheetW)(LPCPROPSHEETHEADERW)
Definition: propsheet.c:120
DWORD dwSize
Definition: prsht.h:214
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
DLGPROC pfnDlgProc
Definition: prsht.h:226
const PROPSHEETHEADERW * LPCPROPSHEETHEADERW
Definition: prsht.h:324
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
static void OnTimer(HWND hwnd, UINT id)
Definition: propsheet.c:44
#define PROPSHEETPAGEW_V2_SIZE
Definition: prsht.h:247
#define LoadLibraryW(x)
Definition: compat.h:606
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
#define ok_int(expression, result)
Definition: atltest.h:134
#define PROPSHEETHEADERA_V1_SIZE
Definition: prsht.h:290
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI IsWindowEnabled(_In_ HWND)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
Definition: propsheet.c:26
START_TEST(propsheet)
Definition: propsheet.c:150
#define PSP_DEFAULT
Definition: prsht.h:22
#define FreeLibrary(x)
Definition: compat.h:607
#define PropSheet_UnChanged(d, w)
Definition: prsht.h:358
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
static FN_CreatePropertySheetPageW pCreatePropertySheetPageW
Definition: propsheet.c:121
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PROPSHEETPAGEA_V1_SIZE
Definition: prsht.h:209
#define WM_TIMER
Definition: winuser.h:1724
static INT_PTR CALLBACK Page1DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: propsheet.c:66
#define WINAPI
Definition: msvc.h:6
#define PSBTN_OK
Definition: prsht.h:149
#define edt1
Definition: dlgs.h:65
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
static void test_ApplyButtonDisabled()
Definition: propsheet.c:125
static const WCHAR L[]
Definition: oid.c:1250
HINSTANCE hInstance
Definition: prsht.h:216
#define WM_COMMAND
Definition: winuser.h:1722
#define PROPSHEETPAGEA_V3_SIZE
Definition: prsht.h:211
const PROPSHEETPAGEW * LPCPROPSHEETPAGEW
Definition: prsht.h:245
HWND WINAPI GetParent(_In_ HWND)
#define ok(value,...)
Definition: atltest.h:57
#define PROPSHEETPAGEA_V2_SIZE
Definition: prsht.h:210
unsigned int UINT
Definition: ndis.h:50
#define PROPSHEETPAGEW_V1_SIZE
Definition: prsht.h:246
#define PROPSHEETPAGEW_V3_SIZE
Definition: prsht.h:248
#define skip(...)
Definition: atltest.h:64
#define CHECK_STRUCT_SIZE(x, y)
Definition: propsheet.c:82
#define PROPSHEETHEADERA_V2_SIZE
Definition: prsht.h:291
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define GetProcAddress(x, y)
Definition: compat.h:612
#define HANDLE_MSG(hwnd, message, fn)
Definition: windowsx.h:297
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDCANCEL
Definition: winuser.h:825
#define PropSheet_PressButton(d, i)
Definition: prsht.h:348
#define PROPSHEETPAGEA_V4_SIZE
Definition: prsht.h:212
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
DWORD dwFlags
Definition: prsht.h:215
struct CFHEADER header
Definition: fdi.c:101
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define EN_CHANGE
Definition: winuser.h:2004