1 /* 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) 6 */ 7 #include "wine/test.h" 8 #include <windows.h> 9 #include <windowsx.h> 10 #include <commctrl.h> 11 #include <prsht.h> 12 13 #define IDC_APPLY_BUTTON 12321 14 15 static BOOL s_bNotified; 16 17 static BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) 18 { 19 s_bNotified = FALSE; 20 SetDlgItemTextW(hwnd, edt1, L"text"); 21 SetTimer(hwnd, 999, 300, NULL); 22 return TRUE; 23 } 24 25 static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) 26 { 27 switch (id) 28 { 29 case IDOK: 30 case IDCANCEL: 31 EndDialog(hwnd, id); 32 break; 33 case edt1: 34 if (codeNotify == EN_CHANGE) 35 { 36 s_bNotified = TRUE; 37 PropSheet_Changed(GetParent(hwnd), hwnd); 38 } 39 break; 40 } 41 } 42 43 static void OnTimer(HWND hwnd, UINT id) 44 { 45 HWND hwndParent, hwndApply; 46 47 KillTimer(hwnd, id); 48 49 ok_int(s_bNotified, TRUE); 50 51 hwndParent = GetParent(hwnd); 52 hwndApply = GetDlgItem(hwndParent, IDC_APPLY_BUTTON); 53 ok_int(IsWindowEnabled(hwndApply), FALSE); 54 55 PropSheet_Changed(hwndParent, hwnd); 56 ok_int(IsWindowEnabled(hwndApply), TRUE); 57 58 PropSheet_UnChanged(hwndParent, hwnd); 59 ok_int(IsWindowEnabled(hwndApply), FALSE); 60 61 PropSheet_PressButton(hwndParent, PSBTN_OK); 62 } 63 64 static INT_PTR CALLBACK 65 Page1DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 66 { 67 switch (uMsg) 68 { 69 HANDLE_MSG(hwnd, WM_INITDIALOG, OnInitDialog); 70 HANDLE_MSG(hwnd, WM_COMMAND, OnCommand); 71 HANDLE_MSG(hwnd, WM_TIMER, OnTimer); 72 } 73 return 0; 74 } 75 76 typedef HPROPSHEETPAGE (WINAPI *FN_CreatePropertySheetPageW)(LPCPROPSHEETPAGEW); 77 typedef int (WINAPI *FN_PropertySheetW)(LPCPROPSHEETHEADERW); 78 79 START_TEST(propsheet) 80 { 81 PROPSHEETPAGEW psp; 82 PROPSHEETHEADERW header; 83 HPROPSHEETPAGE hpsp[1]; 84 HMODULE hComCtl32; 85 FN_CreatePropertySheetPageW pCreatePropertySheetPageW; 86 FN_PropertySheetW pPropertySheetW; 87 88 hComCtl32 = LoadLibraryW(L"comctl32.dll"); 89 pCreatePropertySheetPageW = (FN_CreatePropertySheetPageW)GetProcAddress(hComCtl32, "CreatePropertySheetPageW"); 90 pPropertySheetW = (FN_PropertySheetW)GetProcAddress(hComCtl32, "PropertySheetW"); 91 92 ok(pCreatePropertySheetPageW != NULL, "pCreatePropertySheetPageW was NULL.\n"); 93 ok(pPropertySheetW != NULL, "pPropertySheetW was NULL.\n"); 94 95 if (!pCreatePropertySheetPageW || !pPropertySheetW) 96 { 97 skip("!pCreatePropertySheetPageW || !pPropertySheetW\n"); 98 return; 99 } 100 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"); 109 110 ZeroMemory(&header, sizeof(header)); 111 header.dwSize = sizeof(header); 112 header.dwFlags = 0; 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"); 119 120 FreeLibrary(hComCtl32); 121 } 122