2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Test for property sheet
5 * COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
13 #define IDC_APPLY_BUTTON 12321
15 static BOOL s_bNotified
;
17 static BOOL
OnInitDialog(HWND hwnd
, HWND hwndFocus
, LPARAM lParam
)
20 SetDlgItemTextW(hwnd
, edt1
, L
"text");
21 SetTimer(hwnd
, 999, 300, NULL
);
25 static void OnCommand(HWND hwnd
, int id
, HWND hwndCtl
, UINT codeNotify
)
34 if (codeNotify
== EN_CHANGE
)
37 PropSheet_Changed(GetParent(hwnd
), hwnd
);
43 static void OnTimer(HWND hwnd
, UINT id
)
45 HWND hwndParent
, hwndApply
;
49 ok_int(s_bNotified
, TRUE
);
51 hwndParent
= GetParent(hwnd
);
52 hwndApply
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
53 ok_int(IsWindowEnabled(hwndApply
), FALSE
);
55 PropSheet_Changed(hwndParent
, hwnd
);
56 ok_int(IsWindowEnabled(hwndApply
), TRUE
);
58 PropSheet_UnChanged(hwndParent
, hwnd
);
59 ok_int(IsWindowEnabled(hwndApply
), FALSE
);
61 PropSheet_PressButton(hwndParent
, PSBTN_OK
);
64 static INT_PTR CALLBACK
65 Page1DlgProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
69 HANDLE_MSG(hwnd
, WM_INITDIALOG
, OnInitDialog
);
70 HANDLE_MSG(hwnd
, WM_COMMAND
, OnCommand
);
71 HANDLE_MSG(hwnd
, WM_TIMER
, OnTimer
);
76 typedef HPROPSHEETPAGE (WINAPI
*FN_CreatePropertySheetPageW
)(LPCPROPSHEETPAGEW
);
77 typedef int (WINAPI
*FN_PropertySheetW
)(LPCPROPSHEETHEADERW
);
82 PROPSHEETHEADERW header
;
83 HPROPSHEETPAGE hpsp
[1];
85 FN_CreatePropertySheetPageW pCreatePropertySheetPageW
;
86 FN_PropertySheetW pPropertySheetW
;
88 hComCtl32
= LoadLibraryW(L
"comctl32.dll");
89 pCreatePropertySheetPageW
= (FN_CreatePropertySheetPageW
)GetProcAddress(hComCtl32
, "CreatePropertySheetPageW");
90 pPropertySheetW
= (FN_PropertySheetW
)GetProcAddress(hComCtl32
, "PropertySheetW");
92 ok(pCreatePropertySheetPageW
!= NULL
, "pCreatePropertySheetPageW was NULL.\n");
93 ok(pPropertySheetW
!= NULL
, "pPropertySheetW was NULL.\n");
95 if (!pCreatePropertySheetPageW
|| !pPropertySheetW
)
97 skip("!pCreatePropertySheetPageW || !pPropertySheetW\n");
101 ZeroMemory(&psp
, sizeof(psp
));
102 psp
.dwSize
= sizeof(psp
);
103 psp
.dwFlags
= PSP_DEFAULT
;
104 psp
.hInstance
= GetModuleHandleW(NULL
);
105 psp
.pszTemplate
= MAKEINTRESOURCEW(1);
106 psp
.pfnDlgProc
= Page1DlgProc
;
107 hpsp
[0] = (*pCreatePropertySheetPageW
)(&psp
);
108 ok(hpsp
[0] != NULL
, "hpsp[0] was NULL.\n");
110 ZeroMemory(&header
, sizeof(header
));
111 header
.dwSize
= sizeof(header
);
113 header
.hInstance
= GetModuleHandleW(NULL
);
114 header
.hwndParent
= NULL
;
115 header
.nPages
= ARRAYSIZE(hpsp
);
116 header
.phpage
= hpsp
;
117 header
.pszCaption
= L
"propsheet";
118 ok((*pPropertySheetW
)(&header
) > 0, "PropertySheet returned non-positive value.\n");
120 FreeLibrary(hComCtl32
);