ReactOS  0.4.15-dev-1374-g8d3e80e
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 
39 
40  if (uMsg == WM_ACTIVATE)
42 }
UINT uMsg
Definition: menu.cpp:213
static INT s_nWM_SYSCOMMAND
Definition: CloseWindow.c:14
static BOOL s_bTracing
Definition: CloseWindow.c:12
WPARAM wParam
Definition: combotst.c:138
static INT s_nWM_WINDOWPOSCHANGING
Definition: CloseWindow.c:16
#define WM_NCACTIVATE
Definition: winuser.h:1670
long LONG
Definition: pedump.c:60
static INT s_nWM_ACTIVATE
Definition: CloseWindow.c:17
#define trace
Definition: atltest.h:70
#define WM_TIMER
Definition: winuser.h:1724
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
#define WM_ACTIVATE
Definition: winuser.h:1594
static INT s_nWM_NCACTIVATE
Definition: CloseWindow.c:15
#define WM_SYSCOMMAND
Definition: winuser.h:1723
LPARAM lParam
Definition: combotst.c:139

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");
60  s_nWM_SYSCOMMAND = 0;
61  s_nWM_NCACTIVATE = 0;
63  s_nWM_ACTIVATE = 0;
64  s_bTracing = TRUE;
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");
72  s_bTracing = FALSE;
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");
89  s_nWM_SYSCOMMAND = 0;
90  s_nWM_NCACTIVATE = 0;
92  s_nWM_ACTIVATE = 0;
93  s_bTracing = TRUE;
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");
101  s_bTracing = FALSE;
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");
118  s_nWM_SYSCOMMAND = 0;
119  s_nWM_NCACTIVATE = 0;
121  s_nWM_ACTIVATE = 0;
122  s_bTracing = TRUE;
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");
130  s_bTracing = FALSE;
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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI CloseWindow(_In_ HWND)
#define TRUE
Definition: types.h:120
static INT s_nWM_SYSCOMMAND
Definition: CloseWindow.c:14
#define TIMER_INTERVAL
Definition: CloseWindow.c:19
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
static BOOL s_bTracing
Definition: CloseWindow.c:12
#define SW_RESTORE
Definition: winuser.h:773
BOOL WINAPI DestroyWindow(_In_ HWND)
static INT s_nWM_WINDOWPOSCHANGING
Definition: CloseWindow.c:16
#define FALSE
Definition: types.h:117
HWND WINAPI SetActiveWindow(_In_ HWND)
static INT s_nWM_ACTIVATE
Definition: CloseWindow.c:17
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define trace
Definition: atltest.h:70
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
static INT s_nWM_NCACTIVATE
Definition: CloseWindow.c:15
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
HWND WINAPI GetFocus(void)
Definition: window.c:1909
BOOL WINAPI SetForegroundWindow(_In_ HWND)
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138

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));
183  wc.lpfnWndProc = WindowProc;
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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI CloseWindow(_In_ HWND)
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
static HICON
Definition: imagelist.c:84
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
WORD ATOM
Definition: dimm.idl:113
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI UpdateWindow(_In_ HWND)
#define ZeroMemory
Definition: winbase.h:1648
static const WCHAR s_szClassName[]
Definition: CloseWindow.c:10
#define IDI_APPLICATION
Definition: winuser.h:699
HICON HCURSOR
Definition: windef.h:299
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4291
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define COLOR_3DFACE
Definition: winuser.h:919
WNDPROC lpfnWndProc
Definition: winuser.h:3152
#define CW_USEDEFAULT
Definition: winuser.h:225
LPCWSTR lpszClassName
Definition: winuser.h:3160
BOOL WINAPI DestroyCursor(_In_ HCURSOR)
Definition: cursoricon.c:2654
#define trace
Definition: atltest.h:70
HICON hIcon
Definition: winuser.h:3156
static const WCHAR L[]
Definition: oid.c:1250
#define LoadCursor
Definition: winuser.h:5787
HCURSOR hCursor
Definition: winuser.h:3157
#define SW_SHOWNORMAL
Definition: winuser.h:764
HICON hIcon
Definition: msconfig.c:44
HBRUSH hbrBackground
Definition: winuser.h:3158
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define GetMessage
Definition: winuser.h:5765
HINSTANCE hInstance
Definition: winuser.h:3155
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define LoadIcon
Definition: winuser.h:5788
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CloseWindow.c:146

◆ WindowProc()

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

Definition at line 146 of file CloseWindow.c.

147 {
149  switch (uMsg)
150  {
151  case WM_CREATE:
153  break;
154  case WM_TIMER:
155  OnTimer(hwnd, (UINT)wParam);
156  break;
157  case WM_DESTROY:
158  PostQuitMessage(0);
159  break;
160  default:
161  return DefWindowProc(hwnd, uMsg, wParam, lParam);
162  }
163  return 0;
164 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT uMsg
Definition: menu.cpp:213
static void OnTimer(HWND hwnd, UINT id)
Definition: CloseWindow.c:46
#define TIMER_INTERVAL
Definition: CloseWindow.c:19
WPARAM wParam
Definition: combotst.c:138
static void DoMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CloseWindow.c:22
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_TIMER
Definition: winuser.h:1724
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define WM_CREATE
Definition: winuser.h:1590
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

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().