ReactOS 0.4.17-dev-863-gc5f151a
NcPaintRgn.c File Reference
#include "precomp.h"
Include dependency graph for NcPaintRgn.c:

Go to the source code of this file.

Macros

#define NCPAINT_WHOLE_WINDOW   ((HRGN)1)
 

Functions

static VOID ResetNcPaint (VOID)
 
static LRESULT CALLBACK NcPaintWndProc (_In_ HWND hWnd, _In_ UINT message, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static VOID PumpMessages (VOID)
 
static VOID ExpectWholeFrameRepainted (_In_ HWND hWnd, _In_ PCSTR pszStage)
 
 START_TEST (NcPaintRgn)
 

Variables

static HRGN g_hrgnNcUpdate
 
static BOOL g_bWholeWindow
 
static INT g_cNcPaint
 

Macro Definition Documentation

◆ NCPAINT_WHOLE_WINDOW

#define NCPAINT_WHOLE_WINDOW   ((HRGN)1)

Definition at line 18 of file NcPaintRgn.c.

Function Documentation

◆ ExpectWholeFrameRepainted()

static VOID ExpectWholeFrameRepainted ( _In_ HWND  hWnd,
_In_ PCSTR  pszStage 
)
static

Definition at line 74 of file NcPaintRgn.c.

77{
78 RECT rcWindow, rcClient;
79 HRGN hrgnFrame, hrgnClient, hrgnMissing;
80 INT type;
81
82 GetWindowRect(hWnd, &rcWindow);
83 GetClientRect(hWnd, &rcClient);
84 MapWindowPoints(hWnd, NULL, (PPOINT)&rcClient, 2);
85
86 hrgnFrame = CreateRectRgnIndirect(&rcWindow);
87 hrgnClient = CreateRectRgnIndirect(&rcClient);
88 hrgnMissing = CreateRectRgn(0, 0, 0, 0);
89
90 /* The non-client frame is what the window covers but the client area does not. */
91 CombineRgn(hrgnFrame, hrgnFrame, hrgnClient, RGN_DIFF);
92 type = CombineRgn(hrgnMissing, hrgnFrame, g_hrgnNcUpdate, RGN_DIFF);
93
94 ok(g_cNcPaint > 0, "%s: no WM_NCPAINT was sent\n", pszStage);
95
96 if (!g_bWholeWindow)
97 {
98 RECT rcMissing;
99
100 GetRgnBox(hrgnMissing, &rcMissing);
101 ok(type == NULLREGION,
102 "%s: (%ld,%ld)-(%ld,%ld) of the non-client frame is not in the update region\n",
103 pszStage, rcMissing.left, rcMissing.top, rcMissing.right, rcMissing.bottom);
104 }
105
106 DeleteObject(hrgnMissing);
107 DeleteObject(hrgnClient);
108 DeleteObject(hrgnFrame);
109}
static INT g_cNcPaint
Definition: NcPaintRgn.c:23
static HRGN g_hrgnNcUpdate
Definition: NcPaintRgn.c:21
static BOOL g_bWholeWindow
Definition: NcPaintRgn.c:22
#define ok(value,...)
Definition: atltest.h:57
HWND hWnd
Definition: settings.c:17
#define NULL
Definition: types.h:112
pKey DeleteObject()
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
int32_t INT
Definition: typedefs.h:58
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define RGN_DIFF
Definition: wingdi.h:358
#define NULLREGION
Definition: wingdi.h:361
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by START_TEST().

◆ NcPaintWndProc()

static LRESULT CALLBACK NcPaintWndProc ( _In_ HWND  hWnd,
_In_ UINT  message,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 37 of file NcPaintRgn.c.

42{
43 if (message == WM_NCPAINT)
44 {
45 HRGN hrgn = (HRGN)wParam;
46
47 g_cNcPaint++;
48
51 else if (hrgn != NULL)
53 }
54
56}
#define NCPAINT_WHOLE_WINDOW
Definition: NcPaintRgn.c:18
static HRGN hrgn
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
Definition: tftpd.h:60
#define RGN_OR
Definition: wingdi.h:359
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_NCPAINT
Definition: winuser.h:1715

Referenced by START_TEST().

◆ PumpMessages()

static VOID PumpMessages ( VOID  )
static

Definition at line 60 of file NcPaintRgn.c.

61{
62 MSG msg;
63
64 while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
65 {
68 }
69}
#define msg(x)
Definition: auth_time.c:54
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1207
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)

Referenced by START_TEST().

◆ ResetNcPaint()

static VOID ResetNcPaint ( VOID  )
static

Definition at line 27 of file NcPaintRgn.c.

28{
29 SetRectRgn(g_hrgnNcUpdate, 0, 0, 0, 0);
31 g_cNcPaint = 0;
32}
#define FALSE
Definition: types.h:117
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( NcPaintRgn  )

Definition at line 111 of file NcPaintRgn.c.

112{
113 WNDCLASSEXW wc;
114 HWND hWnd;
115 ATOM atom;
116
117 ZeroMemory(&wc, sizeof(wc));
118 wc.cbSize = sizeof(wc);
122 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
123 wc.lpszClassName = L"NcPaintRgnTestClass";
124
125 atom = RegisterClassExW(&wc);
126 if (atom == 0)
127 {
128 skip("RegisterClassExW failed with %lu\n", GetLastError());
129 return;
130 }
131
132 g_hrgnNcUpdate = CreateRectRgn(0, 0, 0, 0);
133 if (g_hrgnNcUpdate == NULL)
134 {
135 skip("CreateRectRgn failed with %lu\n", GetLastError());
137 return;
138 }
139
141 wc.lpszClassName,
142 L"NcPaintRgn",
144 100, 100, 400, 300,
145 NULL, NULL, wc.hInstance, NULL);
146 if (hWnd == NULL)
147 {
148 skip("CreateWindowExW failed with %lu\n", GetLastError());
151 return;
152 }
153
154 /* Get the window on screen and fully painted, so that the frame is settled. */
157 PumpMessages();
158
159 ResetNcPaint();
162 PumpMessages();
163 ExpectWholeFrameRepainted(hWnd, "maximize");
164
165 ResetNcPaint();
168 PumpMessages();
170
172 PumpMessages();
173
176}
static VOID ExpectWholeFrameRepainted(_In_ HWND hWnd, _In_ PCSTR pszStage)
Definition: NcPaintRgn.c:74
static LRESULT CALLBACK NcPaintWndProc(_In_ HWND hWnd, _In_ UINT message, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: NcPaintRgn.c:37
static VOID PumpMessages(VOID)
Definition: NcPaintRgn.c:60
static VOID ResetNcPaint(VOID)
Definition: NcPaintRgn.c:27
#define skip(...)
Definition: atltest.h:64
WORD ATOM
Definition: dimm.idl:113
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define L(x)
Definition: resources.c:13
#define ZeroMemory
Definition: minwinbase.h:31
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
LPCWSTR lpszClassName
Definition: winuser.h:3334
HBRUSH hbrBackground
Definition: winuser.h:3332
WNDPROC lpfnWndProc
Definition: winuser.h:3326
UINT cbSize
Definition: winuser.h:3324
HCURSOR hCursor
Definition: winuser.h:3331
HINSTANCE hInstance
Definition: winuser.h:3329
const uint16_t * PCWSTR
Definition: typedefs.h:57
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define COLOR_WINDOW
Definition: winuser.h:929
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDC_ARROW
Definition: winuser.h:695
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2474
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)
BOOL WINAPI UpdateWindow(_In_ HWND)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define SW_RESTORE
Definition: winuser.h:790
#define SW_SHOW
Definition: winuser.h:786
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
#define SW_MAXIMIZE
Definition: winuser.h:783
BOOL WINAPI DestroyWindow(_In_ HWND)

Variable Documentation

◆ g_bWholeWindow

BOOL g_bWholeWindow
static

Definition at line 22 of file NcPaintRgn.c.

Referenced by ExpectWholeFrameRepainted(), NcPaintWndProc(), and ResetNcPaint().

◆ g_cNcPaint

INT g_cNcPaint
static

Definition at line 23 of file NcPaintRgn.c.

Referenced by ExpectWholeFrameRepainted(), NcPaintWndProc(), and ResetNcPaint().

◆ g_hrgnNcUpdate

HRGN g_hrgnNcUpdate
static

Definition at line 21 of file NcPaintRgn.c.

Referenced by ExpectWholeFrameRepainted(), NcPaintWndProc(), ResetNcPaint(), and START_TEST().