1 /* 2 * PROJECT: ReactOS API tests 3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+) 4 * PURPOSE: Test for GW_ENABLEDPOPUP 5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 6 */ 7 8 #include "precomp.h" 9 #include <windowsx.h> 10 11 static HWND s_hwnd = NULL; 12 static HWND s_hwndChild1 = NULL; 13 static HWND s_hwndChild2 = NULL; 14 static HWND s_hwndChild3 = NULL; 15 16 static VOID DoTestBody(VOID) 17 { 18 HWND hwndRet; 19 #define CHECK(hwndTarget) do { \ 20 hwndRet = GetWindow(s_hwnd, GW_ENABLEDPOPUP); \ 21 trace("hwndRet: %p\n", hwndRet); \ 22 ok_int(hwndRet == hwndTarget, TRUE); \ 23 } while (0) 24 25 trace("%p, %p, %p, %p\n", s_hwnd, s_hwndChild1, s_hwndChild2, s_hwndChild3); 26 27 CHECK(s_hwndChild3); 28 29 EnableWindow(s_hwndChild3, FALSE); 30 31 CHECK(s_hwndChild2); 32 33 EnableWindow(s_hwndChild2, FALSE); 34 35 CHECK(NULL); 36 37 EnableWindow(s_hwndChild2, TRUE); 38 39 CHECK(s_hwndChild2); 40 41 ShowWindow(s_hwndChild1, SW_HIDE); 42 43 CHECK(s_hwndChild2); 44 45 ShowWindow(s_hwndChild2, SW_HIDE); 46 47 CHECK(NULL); 48 49 ShowWindow(s_hwndChild2, SW_SHOWNOACTIVATE); 50 51 CHECK(s_hwndChild2); 52 53 EnableWindow(s_hwndChild1, TRUE); 54 ShowWindow(s_hwndChild2, SW_SHOWNOACTIVATE); 55 56 CHECK(s_hwndChild2); 57 58 ShowWindow(s_hwndChild1, SW_SHOWNOACTIVATE); 59 60 CHECK(s_hwndChild2); 61 62 ShowWindow(s_hwndChild2, SW_HIDE); 63 64 CHECK(s_hwndChild1); 65 } 66 67 static LRESULT CALLBACK 68 WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 69 { 70 switch (uMsg) 71 { 72 case WM_CREATE: 73 SetTimer(hwnd, 999, 500, NULL); 74 break; 75 case WM_DESTROY: 76 if (s_hwnd == hwnd) 77 { 78 DestroyWindow(s_hwndChild1); 79 DestroyWindow(s_hwndChild2); 80 DestroyWindow(s_hwndChild3); 81 PostQuitMessage(0); 82 } 83 break; 84 case WM_TIMER: 85 KillTimer(hwnd, wParam); 86 if (wParam == 999 && hwnd == s_hwnd) 87 { 88 DoTestBody(); 89 DestroyWindow(hwnd); 90 break; 91 } 92 break; 93 default: 94 return DefWindowProcW(hwnd, uMsg, wParam, lParam); 95 } 96 return 0; 97 } 98 99 START_TEST(GW_ENABLEDPOPUP) 100 { 101 WNDCLASSW wc = { 0 }; 102 MSG msg; 103 104 wc.lpfnWndProc = WindowProc; 105 wc.hInstance = GetModuleHandleW(NULL); 106 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 107 wc.hCursor = LoadCursor(NULL, IDC_ARROW); 108 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 109 wc.lpszClassName = L"GW_ENABLEDPOPUP"; 110 if (!RegisterClassW(&wc)) 111 { 112 skip("RegisterClass failed\n"); 113 return; 114 } 115 116 s_hwnd = CreateWindowW(L"GW_ENABLEDPOPUP", L"GW_ENABLEDPOPUP", 117 WS_OVERLAPPEDWINDOW | WS_VISIBLE, 118 0, 0, 100, 100, 119 NULL, NULL, wc.hInstance, NULL); 120 s_hwndChild1 = CreateWindowW(L"GW_ENABLEDPOPUP", L"Child #1", 121 WS_POPUPWINDOW | WS_CHILD | WS_VISIBLE | WS_DISABLED, 122 100, 100, 100, 100, 123 s_hwnd, NULL, wc.hInstance, NULL); 124 s_hwndChild2 = CreateWindowW(L"GW_ENABLEDPOPUP", L"Child #2", 125 WS_POPUPWINDOW | WS_CHILD | WS_VISIBLE, 126 200, 200, 100, 100, 127 s_hwnd, NULL, wc.hInstance, NULL); 128 s_hwndChild3 = CreateWindowW(L"GW_ENABLEDPOPUP", L"Child #3", 129 WS_POPUPWINDOW | WS_CHILD | WS_VISIBLE, 130 300, 100, 100, 100, 131 s_hwndChild2, NULL, wc.hInstance, NULL); 132 if (!s_hwnd || !s_hwndChild1 || !s_hwndChild2 || !s_hwndChild3) 133 { 134 skip("CreateWindow failed\n"); 135 } 136 137 while (GetMessage(&msg, NULL, 0, 0)) 138 { 139 TranslateMessage(&msg); 140 DispatchMessageW(&msg); 141 } 142 } 143