ReactOS 0.4.16-dev-1537-g4e425b5
ShowWindow.c File Reference
#include "precomp.h"
#include <versionhelpers.h>
Include dependency graph for ShowWindow.c:

Go to the source code of this file.

Classes

struct  TEST_ENTRY
 

Macros

#define STYLE_0   WS_OVERLAPPEDWINDOW
 
#define STYLE_1   (WS_OVERLAPPEDWINDOW | WS_MAXIMIZE)
 
#define STYLE_2   (WS_OVERLAPPEDWINDOW | WS_MINIMIZE)
 
#define STYLE_3   (WS_OVERLAPPEDWINDOW | WS_VISIBLE)
 
#define STYLE_4   (WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MAXIMIZE)
 
#define STYLE_5   (WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MINIMIZE)
 
#define SW_0   -1
 
#define SW_1   SW_HIDE
 
#define SW_2   SW_MAXIMIZE
 
#define SW_3   SW_MINIMIZE
 
#define SW_4   SW_RESTORE
 
#define SW_5   SW_SHOW
 
#define SW_6   SW_SHOWDEFAULT
 
#define SW_7   SW_SHOWMAXIMIZED
 
#define SW_8   SW_SHOWMINIMIZED
 
#define SW_9   SW_SHOWMINNOACTIVE
 
#define SW_10   SW_SHOWNA
 
#define SW_11   SW_SHOWNOACTIVATE
 
#define SW_12   SW_SHOWNORMAL
 
#define RED   RGB(255, 0, 0)
 

Typedefs

typedef struct TEST_ENTRY TEST_ENTRY
 

Functions

static void DoTestEntry (const TEST_ENTRY *pEntry)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID Test_ShowWindow_Main (VOID)
 
static COLORREF CheckColor (VOID)
 
static DWORD WINAPI ForceMinimizeThreadFunc (LPVOID arg)
 
static LRESULT CALLBACK ForceMinimizeWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID Test_WS_FORCEMINIMIZE_Sub (HBRUSH hbr)
 
static VOID Test_WS_FORCEMINIMIZE ()
 
 START_TEST (ShowWindow)
 

Variables

static const CHAR s_name [] = "ShowWindow test window"
 
static const TEST_ENTRY s_entries []
 

Macro Definition Documentation

◆ RED

#define RED   RGB(255, 0, 0)

Definition at line 186 of file ShowWindow.c.

◆ STYLE_0

#define STYLE_0   WS_OVERLAPPEDWINDOW

Definition at line 43 of file ShowWindow.c.

◆ STYLE_1

Definition at line 44 of file ShowWindow.c.

◆ STYLE_2

Definition at line 45 of file ShowWindow.c.

◆ STYLE_3

Definition at line 46 of file ShowWindow.c.

◆ STYLE_4

Definition at line 47 of file ShowWindow.c.

◆ STYLE_5

Definition at line 48 of file ShowWindow.c.

◆ SW_0

#define SW_0   -1

Definition at line 50 of file ShowWindow.c.

◆ SW_1

#define SW_1   SW_HIDE

Definition at line 51 of file ShowWindow.c.

◆ SW_10

#define SW_10   SW_SHOWNA

Definition at line 60 of file ShowWindow.c.

◆ SW_11

Definition at line 61 of file ShowWindow.c.

◆ SW_12

#define SW_12   SW_SHOWNORMAL

Definition at line 62 of file ShowWindow.c.

◆ SW_2

#define SW_2   SW_MAXIMIZE

Definition at line 52 of file ShowWindow.c.

◆ SW_3

#define SW_3   SW_MINIMIZE

Definition at line 53 of file ShowWindow.c.

◆ SW_4

#define SW_4   SW_RESTORE

Definition at line 54 of file ShowWindow.c.

◆ SW_5

#define SW_5   SW_SHOW

Definition at line 55 of file ShowWindow.c.

◆ SW_6

#define SW_6   SW_SHOWDEFAULT

Definition at line 56 of file ShowWindow.c.

◆ SW_7

Definition at line 57 of file ShowWindow.c.

◆ SW_8

Definition at line 58 of file ShowWindow.c.

◆ SW_9

Definition at line 59 of file ShowWindow.c.

Typedef Documentation

◆ TEST_ENTRY

Function Documentation

◆ CheckColor()

static COLORREF CheckColor ( VOID  )
static

Definition at line 188 of file ShowWindow.c.

189{
190 HDC hDC = GetDC(NULL);
191 COLORREF color = GetPixel(hDC, 100, 100);
193 return color;
194}
static HDC hDC
Definition: 3dtext.c:33
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define NULL
Definition: types.h:112
GLuint color
Definition: glext.h:6243
static HDC
Definition: imagelist.c:88
DWORD COLORREF
Definition: windef.h:300
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by ForceMinimizeThreadFunc().

◆ DoTestEntry()

static void DoTestEntry ( const TEST_ENTRY pEntry)
static

Definition at line 22 of file ShowWindow.c.

23{
24 HWND hwnd;
26 BOOL ret;
27
31 ok(!!hwnd, "Line %d: CreateWindowA failed\n", pEntry->lineno);
32
33 ret = !!ShowWindow(hwnd, pEntry->nCmdShow);
34 ok(ret == pEntry->ret, "Line %d: ShowWindow returned %s\n", pEntry->lineno,
35 (ret ? "non-zero" : "zero"));
36
38 ok(style == pEntry->style1, "Line %d: style was 0x%lX\n", pEntry->lineno, style);
39
41}
static const CHAR s_name[]
Definition: ShowWindow.c:20
Arabic default style
Definition: afstyles.h:94
#define ok(value,...)
Definition: atltest.h:57
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
long LONG
Definition: pedump.c:60
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4417
#define GetWindowLongPtrA
Definition: winuser.h:4930
#define CW_USEDEFAULT
Definition: winuser.h:225
#define GWL_STYLE
Definition: winuser.h:863
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by Test_ShowWindow_Main().

◆ ForceMinimizeThreadFunc()

static DWORD WINAPI ForceMinimizeThreadFunc ( LPVOID  arg)
static

Definition at line 197 of file ShowWindow.c.

198{
199 BOOL ret;
200 HWND hwnd = (HWND)arg;
201 DWORD style, exstyle;
202
203 Sleep(100);
205
208 Sleep(100);
209 ok(ret != FALSE, "ret was FALSE\n");
210 ok(CheckColor() != RED, "Color was red\n");
213 ok((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE)) == (WS_POPUP | WS_MINIMIZE | WS_VISIBLE), "style was 0x%08lX\n", style);
214 else
215 ok((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE)) == (WS_POPUP), "style was 0x%08lX\n", style);
217 ok_long(exstyle, 0);
218
220 Sleep(100);
221 ok(CheckColor() != RED, "Color was red\n");
222
225 Sleep(100);
226 ok(ret != FALSE, "ret was FALSE\n");
227 ok(CheckColor() != RED, "Color was red\n");
229 ok((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE)) == (WS_POPUP | WS_MINIMIZE | WS_VISIBLE), "style was 0x%08lX\n", style);
231 ok_long(exstyle, 0);
232
234 Sleep(100);
236
239 Sleep(100);
240 ok(ret != FALSE, "ret was FALSE\n");
241 ok(CheckColor() != RED, "Color was red\n");
244 ok((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE)) == (WS_POPUP | WS_MINIMIZE | WS_VISIBLE), "style was 0x%08lX\n", style);
245 else
246 ok((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE)) == (WS_POPUP), "style was 0x%08lX\n", style);
248 ok_long(exstyle, 0);
249
252 Sleep(100);
254 ok(ret != FALSE, "ret was FALSE\n");
255 else
256 ok_bool_false(ret, "Return was");
257 ok(CheckColor() != RED, "Color was red\n");
260 ok((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE)) == (WS_POPUP | WS_MINIMIZE | WS_VISIBLE), "style was 0x%08lX\n", style);
261 else
262 ok((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE)) == (WS_POPUP), "style was 0x%08lX\n", style);
264 ok_long(exstyle, 0);
265
266 PostMessageW(hwnd, WM_CLOSE, 0, 0);
267 return 0;
268}
static COLORREF CheckColor(VOID)
Definition: ShowWindow.c:188
#define RED
Definition: ShowWindow.c:186
#define ok_bool_false(value, desc)
Definition: apitest.h:64
#define ok_long(expression, result)
Definition: atltest.h:133
#define FALSE
Definition: types.h:117
HANDLE HWND
Definition: compat.h:19
#define WS_POPUP
Definition: pedump.c:616
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_VISIBLE
Definition: pedump.c:620
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define WS_EX_MAKEVISIBLEWHENUNGHOSTED
Definition: undocuser.h:24
VERSIONHELPERAPI IsWindowsVistaOrGreater()
#define SW_SHOWNORMAL
Definition: winuser.h:781
#define WM_CLOSE
Definition: winuser.h:1649
#define GetWindowLongPtrW
Definition: winuser.h:4931
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SW_MINIMIZE
Definition: winuser.h:787
#define SW_FORCEMINIMIZE
Definition: winuser.h:792
#define SetWindowLongPtrW
Definition: winuser.h:5457
#define GWL_EXSTYLE
Definition: winuser.h:862

Referenced by Test_WS_FORCEMINIMIZE_Sub().

◆ ForceMinimizeWndProc()

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

Definition at line 271 of file ShowWindow.c.

272{
273 switch (uMsg)
274 {
275 case WM_DESTROY:
277 break;
278 default:
279 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
280 }
281 return 0;
282}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_DESTROY
Definition: winuser.h:1637

Referenced by Test_WS_FORCEMINIMIZE_Sub().

◆ START_TEST()

START_TEST ( ShowWindow  )

Definition at line 341 of file ShowWindow.c.

342{
345}
static VOID Test_ShowWindow_Main(VOID)
Definition: ShowWindow.c:168
static VOID Test_WS_FORCEMINIMIZE()
Definition: ShowWindow.c:334

◆ Test_ShowWindow_Main()

static VOID Test_ShowWindow_Main ( VOID  )
static

Definition at line 168 of file ShowWindow.c.

169{
170 WNDCLASSA wc;
171 UINT iTest;
172
173 ZeroMemory(&wc, sizeof(wc));
176 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
178 ok_int(1, !!RegisterClassA(&wc));
179
180 for (iTest = 0; iTest < _countof(s_entries); ++iTest)
181 {
182 DoTestEntry(&s_entries[iTest]);
183 }
184}
static void DoTestEntry(const TEST_ENTRY *pEntry)
Definition: ShowWindow.c:22
static const TEST_ENTRY s_entries[]
Definition: ShowWindow.c:64
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ShowWindow.c:153
#define ok_int(expression, result)
Definition: atltest.h:134
unsigned int UINT
Definition: ndis.h:50
#define _countof(array)
Definition: sndvol32.h:70
HBRUSH hbrBackground
Definition: winuser.h:3272
HINSTANCE hInstance
Definition: winuser.h:3269
LPCSTR lpszClassName
Definition: winuser.h:3274
WNDPROC lpfnWndProc
Definition: winuser.h:3266
#define ZeroMemory
Definition: winbase.h:1753
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define COLOR_3DFACE
Definition: winuser.h:940

Referenced by START_TEST().

◆ Test_WS_FORCEMINIMIZE()

static VOID Test_WS_FORCEMINIMIZE ( )
static

Definition at line 334 of file ShowWindow.c.

335{
336 HBRUSH hbr = CreateSolidBrush(RED);
338 DeleteObject(hbr);
339}
static VOID Test_WS_FORCEMINIMIZE_Sub(HBRUSH hbr)
Definition: ShowWindow.c:285
pKey DeleteObject()
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)

Referenced by START_TEST().

◆ Test_WS_FORCEMINIMIZE_Sub()

static VOID Test_WS_FORCEMINIMIZE_Sub ( HBRUSH  hbr)
static

Definition at line 285 of file ShowWindow.c.

286{
287 WNDCLASSW wc;
288 HWND hwnd;
289 DWORD style;
293 MSG msg;
294
295 ZeroMemory(&wc, sizeof(wc));
297 wc.hInstance = hInstance;
300 wc.hbrBackground = hbr;
301 wc.lpszClassName = L"SW_FORCEMINIMIZE";
302 if (!RegisterClassW(&wc))
303 {
304 skip("RegisterClassW failed\n");
305 return;
306 }
307
309 hwnd = CreateWindowExW(0, L"SW_FORCEMINIMIZE", L"SW_FORCEMINIMIZE", style,
310 50, 50, 100, 100, NULL, NULL, hInstance, NULL);
311 if (!hwnd)
312 {
313 skip("CreateWindowExW failed\n");
314 return;
315 }
316
318 if (!hThread)
319 {
320 skip("CreateThread failed\n");
322 return;
323 }
325
326 while (GetMessageW(&msg, NULL, 0, 0))
327 {
330 }
331}
static LRESULT CALLBACK ForceMinimizeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ShowWindow.c:271
static DWORD WINAPI ForceMinimizeThreadFunc(LPVOID arg)
Definition: ShowWindow.c:197
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
HINSTANCE hInstance
Definition: charmap.c:19
#define CloseHandle
Definition: compat.h:739
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define L(x)
Definition: resources.c:13
DWORD dwThreadId
Definition: fdebug.c:31
HANDLE hThread
Definition: wizard.c:28
LPCWSTR lpszClassName
Definition: winuser.h:3287
HBRUSH hbrBackground
Definition: winuser.h:3285
HICON hIcon
Definition: winuser.h:3283
HINSTANCE hInstance
Definition: winuser.h:3282
WNDPROC lpfnWndProc
Definition: winuser.h:3279
HCURSOR hCursor
Definition: winuser.h:3284
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
const uint16_t * PCWSTR
Definition: typedefs.h:57
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:695
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2457
#define IDI_APPLICATION
Definition: winuser.h:712
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2427

Referenced by Test_WS_FORCEMINIMIZE().

◆ WindowProc()

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

Definition at line 153 of file ShowWindow.c.

154{
155 switch (uMsg)
156 {
157 case WM_CREATE:
158 return 0;
159 case WM_DESTROY:
161 break;
162 default:
163 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
164 }
165 return 0;
166}
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1636

Referenced by Test_ShowWindow_Main().

Variable Documentation

◆ s_entries

const TEST_ENTRY s_entries[]
static

Definition at line 64 of file ShowWindow.c.

Referenced by Test_ShowWindow_Main().

◆ s_name

const CHAR s_name[] = "ShowWindow test window"
static