ReactOS 0.4.15-dev-7961-gdcf9eb0
CloseWindow.c File Reference
#include "precomp.h"
Include dependency graph for CloseWindow.c:

Go to the source code of this file.

Macros

#define TIMER_INTERVAL   200
 

Functions

static void DoMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static void OnTimer (HWND hwnd, UINT id)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
 START_TEST (CloseWindow)
 

Variables

static const WCHAR s_szClassName [] = L"CloseWindowTest"
 
static BOOL s_bTracing = FALSE
 
static INT s_nWM_SYSCOMMAND = 0
 
static INT s_nWM_NCACTIVATE = 0
 
static INT s_nWM_WINDOWPOSCHANGING = 0
 
static INT s_nWM_ACTIVATE = 0
 

Macro Definition Documentation

◆ TIMER_INTERVAL

#define TIMER_INTERVAL   200

Definition at line 19 of file CloseWindow.c.

Function Documentation

◆ DoMessage()

static void DoMessage ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 22 of file CloseWindow.c.

23{
24 if (uMsg == WM_TIMER || !s_bTracing)
25 return;
26
27 trace("uMsg:0x%04X, wParam:0x%08lX, lParam:0x%08lX\n", uMsg, (LONG)wParam, (LONG)lParam);
28
29 if (uMsg == WM_SYSCOMMAND)
30 {
32 }
33
34 if (uMsg == WM_NCACTIVATE)
36
37 if (uMsg == WM_WINDOWPOSCHANGING)
39
40 if (uMsg == WM_ACTIVATE)
42}
static INT s_nWM_SYSCOMMAND
Definition: CloseWindow.c:14
static BOOL s_bTracing
Definition: CloseWindow.c:12
static INT s_nWM_ACTIVATE
Definition: CloseWindow.c:17
static INT s_nWM_NCACTIVATE
Definition: CloseWindow.c:15
static INT s_nWM_WINDOWPOSCHANGING
Definition: CloseWindow.c:16
#define trace
Definition: atltest.h:70
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
long LONG
Definition: pedump.c:60
#define WM_SYSCOMMAND
Definition: winuser.h:1741
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1661
#define WM_ACTIVATE
Definition: winuser.h:1612
#define WM_NCACTIVATE
Definition: winuser.h:1688
#define WM_TIMER
Definition: winuser.h:1742

Referenced by WindowProc().

◆ OnTimer()

static void OnTimer ( HWND  hwnd,
UINT  id 
)
static

Definition at line 46 of file CloseWindow.c.

47{
48 KillTimer(hwnd, id);
49 switch (id)
50 {
51 //
52 // SetActiveWindow(GetDesktopWindow());
53 //
54 case 0:
57 ok(GetForegroundWindow() == NULL, "GetForegroundWindow() != NULL\n");
58 ok(GetActiveWindow() == NULL, "GetActiveWindow() != NULL\n");
59 ok(GetFocus() == NULL, "GetFocus() != NULL\n");
65 trace("CloseWindow(hwnd): tracing...\n");
66 ok(CloseWindow(hwnd), "CloseWindow failed\n");
67 break;
68 case 1:
69 ok(GetForegroundWindow() == NULL, "GetForegroundWindow() != NULL\n");
70 ok(GetActiveWindow() == hwnd, "GetActiveWindow() != hwnd\n");
71 ok(GetFocus() == NULL, "GetFocus() != NULL\n");
73 trace("CloseWindow(hwnd): tracing done\n");
74 ok(s_nWM_SYSCOMMAND == 0, "WM_SYSCOMMAND: %d\n", s_nWM_SYSCOMMAND);
75 ok(s_nWM_NCACTIVATE == 1, "WM_NCACTIVATE: %d\n", s_nWM_NCACTIVATE);
76 ok(s_nWM_WINDOWPOSCHANGING == 2, "WM_WINDOWPOSCHANGING: %d\n", s_nWM_WINDOWPOSCHANGING);
77 ok(s_nWM_ACTIVATE == 1, "WM_ACTIVATE: %d\n", s_nWM_ACTIVATE);
79 break;
80 //
81 // SetActiveWindow(hwnd);
82 //
83 case 2:
86 ok(GetForegroundWindow() == NULL, "GetForegroundWindow() != NULL\n");
87 ok(GetActiveWindow() == hwnd, "GetActiveWindow() != hwnd\n");
88 ok(GetFocus() == hwnd, "GetFocus() != hwnd\n");
94 trace("CloseWindow(hwnd): tracing...\n");
95 ok(CloseWindow(hwnd), "CloseWindow failed\n");
96 break;
97 case 3:
98 ok(GetForegroundWindow() == NULL, "GetForegroundWindow() != NULL\n");
99 ok(GetActiveWindow() == hwnd, "GetActiveWindow() != hwnd\n");
100 ok(GetFocus() == NULL, "GetFocus() != NULL\n");
102 trace("CloseWindow(hwnd): tracing done\n");
103 ok(s_nWM_SYSCOMMAND == 0, "WM_SYSCOMMAND: %d\n", s_nWM_SYSCOMMAND);
104 ok(s_nWM_NCACTIVATE == 0, "WM_NCACTIVATE: %d\n", s_nWM_NCACTIVATE);
105 ok(s_nWM_WINDOWPOSCHANGING == 1, "WM_WINDOWPOSCHANGING: %d\n", s_nWM_WINDOWPOSCHANGING);
106 ok(s_nWM_ACTIVATE == 0, "WM_ACTIVATE: %d\n", s_nWM_ACTIVATE);
108 break;
109 //
110 // SetForegroundWindow(hwnd);
111 //
112 case 4:
115 ok(GetForegroundWindow() == hwnd, "GetForegroundWindow() != hwnd\n");
116 ok(GetActiveWindow() == hwnd, "GetActiveWindow() != hwnd\n");
117 ok(GetFocus() == hwnd, "GetFocus() != hwnd\n");
121 s_nWM_ACTIVATE = 0;
123 trace("CloseWindow(hwnd): tracing...\n");
124 ok(CloseWindow(hwnd), "CloseWindow failed\n");
125 break;
126 case 5:
127 ok(GetForegroundWindow() == hwnd, "GetForegroundWindow() != hwnd\n");
128 ok(GetActiveWindow() == hwnd, "GetActiveWindow() != hwnd\n");
129 ok(GetFocus() == NULL, "GetFocus() != NULL\n");
131 trace("CloseWindow(hwnd): tracing done\n");
132 ok(s_nWM_SYSCOMMAND == 0, "WM_SYSCOMMAND: %d\n", s_nWM_SYSCOMMAND);
133 ok(s_nWM_NCACTIVATE == 0, "WM_NCACTIVATE: %d\n", s_nWM_NCACTIVATE);
134 ok(s_nWM_WINDOWPOSCHANGING == 1, "WM_WINDOWPOSCHANGING: %d\n", s_nWM_WINDOWPOSCHANGING);
135 ok(s_nWM_ACTIVATE == 0, "WM_ACTIVATE: %d\n", s_nWM_ACTIVATE);
137 break;
138 default: // finish
140 return;
141 }
142 SetTimer(hwnd, id + 1, TIMER_INTERVAL, NULL);
143}
#define TIMER_INTERVAL
Definition: CloseWindow.c:19
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HWND WINAPI GetFocus(void)
Definition: window.c:1893
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
BOOL WINAPI SetForegroundWindow(_In_ HWND)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
HWND WINAPI SetActiveWindow(_In_ HWND)
#define SW_RESTORE
Definition: winuser.h:779
BOOL WINAPI CloseWindow(_In_ HWND)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by WindowProc().

◆ START_TEST()

START_TEST ( CloseWindow  )

Definition at line 166 of file CloseWindow.c.

167{
168 WNDCLASSW wc;
169 HICON hIcon;
170 HCURSOR hCursor;
171 ATOM atom;
172 HWND hwnd;
173 MSG msg;
174
175 ok(!CloseWindow(NULL), "CloseWindow(NULL) should be failed\n");
176
178 ok(hIcon != NULL, "hIcon was NULL\n");
179 hCursor = LoadCursor(NULL, IDC_ARROW);
180 ok(hCursor != NULL, "hCursor was NULL\n");
181
182 ZeroMemory(&wc, sizeof(wc));
185 wc.hIcon = hIcon;
186 wc.hCursor = hCursor;
187 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
189 atom = RegisterClassW(&wc);
190 ok(atom != 0, "RegisterClassW failed\n");
191
192 if (!atom)
193 {
194 skip("atom is zero\n");
196 DestroyCursor(hCursor);
197 return;
198 }
199
200 hwnd = CreateWindowW(s_szClassName, L"CloseWindow testcase", WS_OVERLAPPEDWINDOW,
201 CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
203 ok(hwnd != NULL, "CreateWindowW failed\n");
204 trace("hwnd: %p\n", hwnd);
205
206 if (!hwnd)
207 {
208 skip("hwnd is NULL\n");
211 DestroyCursor(hCursor);
212 return;
213 }
214
217
218 while (GetMessage(&msg, NULL, 0, 0))
219 {
222 }
223
226 DestroyCursor(hCursor);
227}
static const WCHAR s_szClassName[]
Definition: CloseWindow.c:10
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CloseWindow.c:146
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
WORD ATOM
Definition: dimm.idl:113
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
LPCWSTR lpszClassName
Definition: winuser.h:3185
HBRUSH hbrBackground
Definition: winuser.h:3183
HICON hIcon
Definition: winuser.h:3181
HINSTANCE hInstance
Definition: winuser.h:3180
WNDPROC lpfnWndProc
Definition: winuser.h:3177
HCURSOR hCursor
Definition: winuser.h:3182
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define ZeroMemory
Definition: winbase.h:1712
HICON HCURSOR
Definition: windef.h:299
#define SW_SHOWNORMAL
Definition: winuser.h:770
BOOL WINAPI DestroyCursor(_In_ HCURSOR)
Definition: cursoricon.c:2689
BOOL WINAPI TranslateMessage(_In_ const MSG *)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
#define IDI_APPLICATION
Definition: winuser.h:704
#define GetMessage
Definition: winuser.h:5790
#define LoadIcon
Definition: winuser.h:5813
BOOL WINAPI UpdateWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5812
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
#define CW_USEDEFAULT
Definition: winuser.h:225
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
#define DispatchMessage
Definition: winuser.h:5765
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053
#define COLOR_3DFACE
Definition: winuser.h:929

◆ WindowProc()

static LRESULT CALLBACK WindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 146 of file CloseWindow.c.

147{
148 DoMessage(hwnd, uMsg, wParam, lParam);
149 switch (uMsg)
150 {
151 case WM_CREATE:
153 break;
154 case WM_TIMER:
156 break;
157 case WM_DESTROY:
159 break;
160 default:
161 return DefWindowProc(hwnd, uMsg, wParam, lParam);
162 }
163 return 0;
164}
static void OnTimer(HWND hwnd, UINT id)
Definition: CloseWindow.c:46
static void DoMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CloseWindow.c:22
unsigned int UINT
Definition: ndis.h:50
#define DefWindowProc
Definition: ros2win.h:31
#define WM_CREATE
Definition: winuser.h:1608
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by START_TEST().

Variable Documentation

◆ s_bTracing

BOOL s_bTracing = FALSE
static

Definition at line 12 of file CloseWindow.c.

Referenced by DoMessage(), and OnTimer().

◆ s_nWM_ACTIVATE

INT s_nWM_ACTIVATE = 0
static

Definition at line 17 of file CloseWindow.c.

Referenced by DoMessage(), and OnTimer().

◆ s_nWM_NCACTIVATE

INT s_nWM_NCACTIVATE = 0
static

Definition at line 15 of file CloseWindow.c.

Referenced by DoMessage(), and OnTimer().

◆ s_nWM_SYSCOMMAND

INT s_nWM_SYSCOMMAND = 0
static

Definition at line 14 of file CloseWindow.c.

Referenced by DoMessage(), and OnTimer().

◆ s_nWM_WINDOWPOSCHANGING

INT s_nWM_WINDOWPOSCHANGING = 0
static

Definition at line 16 of file CloseWindow.c.

Referenced by DoMessage(), and OnTimer().

◆ s_szClassName

const WCHAR s_szClassName[] = L"CloseWindowTest"
static

Definition at line 10 of file CloseWindow.c.

Referenced by START_TEST().