1*a9b77d89SMarek Benc /*
2*a9b77d89SMarek Benc  * PROJECT:     ReactOS API tests
3*a9b77d89SMarek Benc  * LICENSE:     MIT (https://spdx.org/licenses/MIT)
4*a9b77d89SMarek Benc  * PURPOSE:     Tests window redrawing when scrollbars appear or disappear
5*a9b77d89SMarek Benc  * COPYRIGHT:   Copyright 2024 Marek Benc <benc.marek.elektro98@proton.me>
6*a9b77d89SMarek Benc  */
7*a9b77d89SMarek Benc 
8*a9b77d89SMarek Benc #include "precomp.h"
9*a9b77d89SMarek Benc 
10*a9b77d89SMarek Benc #define TEST_CLASS_NAME   L"ScrollBarRedraw"
11*a9b77d89SMarek Benc #define TEST_WINDOW_TITLE L"ScrollBarRedraw"
12*a9b77d89SMarek Benc 
13*a9b77d89SMarek Benc static LRESULT CALLBACK WindowProc(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam);
14*a9b77d89SMarek Benc 
15*a9b77d89SMarek Benc #define TEST_COLOR_COUNT 16
16*a9b77d89SMarek Benc 
17*a9b77d89SMarek Benc /* Standard Windows 16-Color VGA Color palette. */
18*a9b77d89SMarek Benc static COLORREF Colors[] =
19*a9b77d89SMarek Benc {
20*a9b77d89SMarek Benc     RGB(0x00, 0x00, 0x00),  /* Black */
21*a9b77d89SMarek Benc     RGB(0x00, 0x00, 0x80),  /* Dark Blue */
22*a9b77d89SMarek Benc     RGB(0x00, 0x80, 0x00),  /* Dark Green */
23*a9b77d89SMarek Benc     RGB(0x00, 0x80, 0x80),  /* Dark Cyan */
24*a9b77d89SMarek Benc     RGB(0x80, 0x00, 0x00),  /* Dark Red */
25*a9b77d89SMarek Benc     RGB(0x80, 0x00, 0x80),  /* Dark Magenta */
26*a9b77d89SMarek Benc     RGB(0x80, 0x80, 0x00),  /* Dark Yellow */
27*a9b77d89SMarek Benc     RGB(0xC0, 0xC0, 0xC0),  /* Light Gray */
28*a9b77d89SMarek Benc     RGB(0x80, 0x80, 0x80),  /* Dark Gray */
29*a9b77d89SMarek Benc     RGB(0x00, 0x00, 0xFF),  /* Blue */
30*a9b77d89SMarek Benc     RGB(0x00, 0xFF, 0x00),  /* Green */
31*a9b77d89SMarek Benc     RGB(0x00, 0xFF, 0xFF),  /* Cyan */
32*a9b77d89SMarek Benc     RGB(0xFF, 0x00, 0x00),  /* Red */
33*a9b77d89SMarek Benc     RGB(0xFF, 0x00, 0xFF),  /* Magenta */
34*a9b77d89SMarek Benc     RGB(0xFF, 0xFF, 0x00),  /* Yellow */
35*a9b77d89SMarek Benc     RGB(0xFF, 0xFF, 0xFF)   /* White */
36*a9b77d89SMarek Benc };
37*a9b77d89SMarek Benc static HBRUSH ColorBrushes[TEST_COLOR_COUNT] = { 0 };
38*a9b77d89SMarek Benc 
39*a9b77d89SMarek Benc static BOOL HaveHRedraw = FALSE;
40*a9b77d89SMarek Benc static BOOL HaveVRedraw = FALSE;
41*a9b77d89SMarek Benc static BOOL WindowCreatedOk = FALSE;
42*a9b77d89SMarek Benc 
43*a9b77d89SMarek Benc typedef enum _FSM_STATE
44*a9b77d89SMarek Benc {
45*a9b77d89SMarek Benc     FSM_STATE_START,
46*a9b77d89SMarek Benc     FSM_STATE_VSCR_SHOWN,
47*a9b77d89SMarek Benc     FSM_STATE_VSCR_HIDDEN,
48*a9b77d89SMarek Benc     FSM_STATE_HSCR_SHOWN,
49*a9b77d89SMarek Benc     FSM_STATE_HSCR_HIDDEN,
50*a9b77d89SMarek Benc     FSM_STATE_BSCR_SHOWN,
51*a9b77d89SMarek Benc     FSM_STATE_BSCR_HIDDEN,
52*a9b77d89SMarek Benc     FSM_STATE_WIDTH_SHRUNK,
53*a9b77d89SMarek Benc     FSM_STATE_WIDTH_EXPANDED,
54*a9b77d89SMarek Benc     FSM_STATE_HEIGHT_SHRUNK,
55*a9b77d89SMarek Benc     FSM_STATE_HEIGHT_EXPANDED,
56*a9b77d89SMarek Benc     FSM_STATE_BOTH_SHRUNK,
57*a9b77d89SMarek Benc     FSM_STATE_BOTH_EXPANDED,
58*a9b77d89SMarek Benc     FSM_STATE_END
59*a9b77d89SMarek Benc } FSM_STATE;
60*a9b77d89SMarek Benc 
61*a9b77d89SMarek Benc #define FSM_STEP_PERIOD_MS 250
62*a9b77d89SMarek Benc 
63*a9b77d89SMarek Benc static UINT_PTR FsmTimer = 0;
64*a9b77d89SMarek Benc static UINT CurrentColor = 0;
65*a9b77d89SMarek Benc static FSM_STATE FsmState = FSM_STATE_START;
66*a9b77d89SMarek Benc 
67*a9b77d89SMarek Benc static int ClientWidth = 0;
68*a9b77d89SMarek Benc static int ClientHeight = 0;
69*a9b77d89SMarek Benc 
70*a9b77d89SMarek Benc static int OrigWidth = 0;
71*a9b77d89SMarek Benc static int OrigHeight = 0;
72*a9b77d89SMarek Benc static int SmallWidth = 0;
73*a9b77d89SMarek Benc static int SmallHeight = 0;
74*a9b77d89SMarek Benc 
ColorsCleanup(void)75*a9b77d89SMarek Benc static void ColorsCleanup(void)
76*a9b77d89SMarek Benc {
77*a9b77d89SMarek Benc     UINT Iter;
78*a9b77d89SMarek Benc 
79*a9b77d89SMarek Benc     for (Iter = 0; Iter < _countof(ColorBrushes); Iter++)
80*a9b77d89SMarek Benc     {
81*a9b77d89SMarek Benc         if (ColorBrushes[Iter] != NULL)
82*a9b77d89SMarek Benc         {
83*a9b77d89SMarek Benc             DeleteObject(ColorBrushes[Iter]);
84*a9b77d89SMarek Benc             ColorBrushes[Iter] = NULL;
85*a9b77d89SMarek Benc         }
86*a9b77d89SMarek Benc     }
87*a9b77d89SMarek Benc }
88*a9b77d89SMarek Benc 
ColorsInit(void)89*a9b77d89SMarek Benc static BOOL ColorsInit(void)
90*a9b77d89SMarek Benc {
91*a9b77d89SMarek Benc     UINT Iter;
92*a9b77d89SMarek Benc 
93*a9b77d89SMarek Benc     assert(_countof(Colors) == _countof(ColorBrushes));
94*a9b77d89SMarek Benc 
95*a9b77d89SMarek Benc     for (Iter = 0; Iter < _countof(ColorBrushes); Iter++)
96*a9b77d89SMarek Benc     {
97*a9b77d89SMarek Benc         ColorBrushes[Iter] = CreateSolidBrush(Colors[Iter]);
98*a9b77d89SMarek Benc         if (ColorBrushes[Iter] == NULL)
99*a9b77d89SMarek Benc         {
100*a9b77d89SMarek Benc             ColorsCleanup();
101*a9b77d89SMarek Benc             return FALSE;
102*a9b77d89SMarek Benc         }
103*a9b77d89SMarek Benc     }
104*a9b77d89SMarek Benc 
105*a9b77d89SMarek Benc     return TRUE;
106*a9b77d89SMarek Benc }
107*a9b77d89SMarek Benc 
RunTestWindow(PCWSTR ClassName,PCWSTR WindowTitle,UINT ClassStyle)108*a9b77d89SMarek Benc static void RunTestWindow(PCWSTR ClassName, PCWSTR WindowTitle, UINT ClassStyle)
109*a9b77d89SMarek Benc {
110*a9b77d89SMarek Benc     WNDCLASSW Class = { 0 };
111*a9b77d89SMarek Benc     HWND Window;
112*a9b77d89SMarek Benc     MSG  Message;
113*a9b77d89SMarek Benc     HINSTANCE hInst;
114*a9b77d89SMarek Benc 
115*a9b77d89SMarek Benc     CurrentColor = 0;
116*a9b77d89SMarek Benc     hInst = GetModuleHandleW(NULL);
117*a9b77d89SMarek Benc 
118*a9b77d89SMarek Benc     Class.style         = ClassStyle;
119*a9b77d89SMarek Benc     Class.lpfnWndProc   = WindowProc;
120*a9b77d89SMarek Benc     Class.cbClsExtra    = 0;
121*a9b77d89SMarek Benc     Class.cbWndExtra    = 0;
122*a9b77d89SMarek Benc     Class.hInstance     = hInst;
123*a9b77d89SMarek Benc     Class.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
124*a9b77d89SMarek Benc     Class.hCursor       = LoadCursor(NULL, IDC_ARROW);
125*a9b77d89SMarek Benc     Class.hbrBackground = ColorBrushes[CurrentColor];
126*a9b77d89SMarek Benc     Class.lpszMenuName  = NULL;
127*a9b77d89SMarek Benc     Class.lpszClassName = ClassName;
128*a9b77d89SMarek Benc 
129*a9b77d89SMarek Benc     if (!RegisterClassW(&Class))
130*a9b77d89SMarek Benc     {
131*a9b77d89SMarek Benc         skip("Failed to register window class '%ls', code: %ld\n",
132*a9b77d89SMarek Benc              ClassName, GetLastError());
133*a9b77d89SMarek Benc         return;
134*a9b77d89SMarek Benc     }
135*a9b77d89SMarek Benc 
136*a9b77d89SMarek Benc     Window = CreateWindowW(ClassName,
137*a9b77d89SMarek Benc                            WindowTitle,
138*a9b77d89SMarek Benc                            WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL,
139*a9b77d89SMarek Benc                            CW_USEDEFAULT,
140*a9b77d89SMarek Benc                            CW_USEDEFAULT,
141*a9b77d89SMarek Benc                            CW_USEDEFAULT,
142*a9b77d89SMarek Benc                            CW_USEDEFAULT,
143*a9b77d89SMarek Benc                            NULL,
144*a9b77d89SMarek Benc                            NULL,
145*a9b77d89SMarek Benc                            hInst,
146*a9b77d89SMarek Benc                            NULL);
147*a9b77d89SMarek Benc     if (Window == NULL)
148*a9b77d89SMarek Benc     {
149*a9b77d89SMarek Benc         skip("Failed to create window of class '%ls', code: %ld\n",
150*a9b77d89SMarek Benc              ClassName, GetLastError());
151*a9b77d89SMarek Benc         return;
152*a9b77d89SMarek Benc     }
153*a9b77d89SMarek Benc 
154*a9b77d89SMarek Benc     ShowWindow(Window, SW_SHOWNORMAL);
155*a9b77d89SMarek Benc     UpdateWindow(Window);
156*a9b77d89SMarek Benc 
157*a9b77d89SMarek Benc     while (GetMessageW(&Message, NULL, 0, 0))
158*a9b77d89SMarek Benc     {
159*a9b77d89SMarek Benc         TranslateMessage(&Message);
160*a9b77d89SMarek Benc         DispatchMessageW(&Message);
161*a9b77d89SMarek Benc     }
162*a9b77d89SMarek Benc }
163*a9b77d89SMarek Benc 
START_TEST(ScrollBarRedraw)164*a9b77d89SMarek Benc START_TEST(ScrollBarRedraw)
165*a9b77d89SMarek Benc {
166*a9b77d89SMarek Benc     if (!ColorsInit())
167*a9b77d89SMarek Benc     {
168*a9b77d89SMarek Benc         skip("Failed to initialize colors and solid color brushes\n");
169*a9b77d89SMarek Benc         return;
170*a9b77d89SMarek Benc     }
171*a9b77d89SMarek Benc 
172*a9b77d89SMarek Benc     trace("Running test without specifying either CS_HREDRAW or CS_HREDRAW\n");
173*a9b77d89SMarek Benc     HaveHRedraw = FALSE;
174*a9b77d89SMarek Benc     HaveVRedraw = FALSE;
175*a9b77d89SMarek Benc     RunTestWindow(TEST_CLASS_NAME   L"NoRedraw",
176*a9b77d89SMarek Benc                   TEST_WINDOW_TITLE L" (No Redraw Flags)",
177*a9b77d89SMarek Benc                   0);
178*a9b77d89SMarek Benc 
179*a9b77d89SMarek Benc     trace("Running test with CS_HREDRAW\n");
180*a9b77d89SMarek Benc     HaveHRedraw = TRUE;
181*a9b77d89SMarek Benc     HaveVRedraw = FALSE;
182*a9b77d89SMarek Benc     RunTestWindow(TEST_CLASS_NAME   L"HRedraw",
183*a9b77d89SMarek Benc                   TEST_WINDOW_TITLE L" (CS_HREDRAW)",
184*a9b77d89SMarek Benc                   CS_HREDRAW);
185*a9b77d89SMarek Benc 
186*a9b77d89SMarek Benc     trace("Running test with CS_VREDRAW\n");
187*a9b77d89SMarek Benc     HaveHRedraw = FALSE;
188*a9b77d89SMarek Benc     HaveVRedraw = TRUE;
189*a9b77d89SMarek Benc     RunTestWindow(TEST_CLASS_NAME   L"VRedraw",
190*a9b77d89SMarek Benc                   TEST_WINDOW_TITLE L" (CS_VREDRAW)",
191*a9b77d89SMarek Benc                   CS_VREDRAW);
192*a9b77d89SMarek Benc 
193*a9b77d89SMarek Benc     trace("Running test with both CS_HREDRAW and CS_VREDRAW\n");
194*a9b77d89SMarek Benc     HaveHRedraw = TRUE;
195*a9b77d89SMarek Benc     HaveVRedraw = TRUE;
196*a9b77d89SMarek Benc     RunTestWindow(TEST_CLASS_NAME   L"HRedrawVRedraw",
197*a9b77d89SMarek Benc                   TEST_WINDOW_TITLE L" (CS_HREDRAW | CS_VREDRAW)",
198*a9b77d89SMarek Benc                   CS_HREDRAW | CS_VREDRAW);
199*a9b77d89SMarek Benc 
200*a9b77d89SMarek Benc     trace("Test complete\n");
201*a9b77d89SMarek Benc     ColorsCleanup();
202*a9b77d89SMarek Benc }
203*a9b77d89SMarek Benc 
HideVertScrollBar(HWND Window)204*a9b77d89SMarek Benc static void HideVertScrollBar(HWND Window)
205*a9b77d89SMarek Benc {
206*a9b77d89SMarek Benc     SCROLLINFO ScrollInfo;
207*a9b77d89SMarek Benc 
208*a9b77d89SMarek Benc     ScrollInfo.cbSize = sizeof(ScrollInfo);
209*a9b77d89SMarek Benc     ScrollInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
210*a9b77d89SMarek Benc     ScrollInfo.nPage = ClientHeight;
211*a9b77d89SMarek Benc 
212*a9b77d89SMarek Benc     ScrollInfo.nMin = 0;
213*a9b77d89SMarek Benc     ScrollInfo.nMax = ClientHeight - 1;
214*a9b77d89SMarek Benc     ScrollInfo.nPos = 0;
215*a9b77d89SMarek Benc 
216*a9b77d89SMarek Benc     SetScrollInfo(Window, SB_VERT, &ScrollInfo, TRUE);
217*a9b77d89SMarek Benc }
218*a9b77d89SMarek Benc 
ShowVertScrollBar(HWND Window)219*a9b77d89SMarek Benc static void ShowVertScrollBar(HWND Window)
220*a9b77d89SMarek Benc {
221*a9b77d89SMarek Benc     SCROLLINFO ScrollInfo;
222*a9b77d89SMarek Benc 
223*a9b77d89SMarek Benc     ScrollInfo.cbSize = sizeof(ScrollInfo);
224*a9b77d89SMarek Benc     ScrollInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
225*a9b77d89SMarek Benc     ScrollInfo.nPage = ClientHeight;
226*a9b77d89SMarek Benc 
227*a9b77d89SMarek Benc     ScrollInfo.nMin = 0;
228*a9b77d89SMarek Benc     ScrollInfo.nMax = (3 * ClientHeight) - 1;
229*a9b77d89SMarek Benc     ScrollInfo.nPos = 0;
230*a9b77d89SMarek Benc 
231*a9b77d89SMarek Benc     SetScrollInfo(Window, SB_VERT, &ScrollInfo, TRUE);
232*a9b77d89SMarek Benc }
233*a9b77d89SMarek Benc 
HideHorzScrollBar(HWND Window)234*a9b77d89SMarek Benc static void HideHorzScrollBar(HWND Window)
235*a9b77d89SMarek Benc {
236*a9b77d89SMarek Benc     SCROLLINFO ScrollInfo;
237*a9b77d89SMarek Benc 
238*a9b77d89SMarek Benc     ScrollInfo.cbSize = sizeof(ScrollInfo);
239*a9b77d89SMarek Benc     ScrollInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
240*a9b77d89SMarek Benc     ScrollInfo.nPage = ClientWidth;
241*a9b77d89SMarek Benc 
242*a9b77d89SMarek Benc     ScrollInfo.nMin = 0;
243*a9b77d89SMarek Benc     ScrollInfo.nMax = ClientWidth - 1;
244*a9b77d89SMarek Benc     ScrollInfo.nPos = 0;
245*a9b77d89SMarek Benc 
246*a9b77d89SMarek Benc     SetScrollInfo(Window, SB_HORZ, &ScrollInfo, TRUE);
247*a9b77d89SMarek Benc }
248*a9b77d89SMarek Benc 
ShowHorzScrollBar(HWND Window)249*a9b77d89SMarek Benc static void ShowHorzScrollBar(HWND Window)
250*a9b77d89SMarek Benc {
251*a9b77d89SMarek Benc     SCROLLINFO ScrollInfo;
252*a9b77d89SMarek Benc 
253*a9b77d89SMarek Benc     ScrollInfo.cbSize = sizeof(ScrollInfo);
254*a9b77d89SMarek Benc     ScrollInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
255*a9b77d89SMarek Benc     ScrollInfo.nPage = ClientWidth;
256*a9b77d89SMarek Benc 
257*a9b77d89SMarek Benc     ScrollInfo.nMin = 0;
258*a9b77d89SMarek Benc     ScrollInfo.nMax = (3 * ClientWidth) - 1;
259*a9b77d89SMarek Benc     ScrollInfo.nPos = 0;
260*a9b77d89SMarek Benc 
261*a9b77d89SMarek Benc     SetScrollInfo(Window, SB_HORZ, &ScrollInfo, TRUE);
262*a9b77d89SMarek Benc }
263*a9b77d89SMarek Benc 
FsmStep(HWND Window)264*a9b77d89SMarek Benc static int FsmStep(HWND Window)
265*a9b77d89SMarek Benc {
266*a9b77d89SMarek Benc     static COLORREF PrevColor = CLR_INVALID;
267*a9b77d89SMarek Benc     COLORREF Color = CLR_INVALID;
268*a9b77d89SMarek Benc     HDC hdc = NULL;
269*a9b77d89SMarek Benc 
270*a9b77d89SMarek Benc     if (FsmState != FSM_STATE_END)
271*a9b77d89SMarek Benc     {
272*a9b77d89SMarek Benc         hdc = GetDC(Window);
273*a9b77d89SMarek Benc         if (hdc == NULL)
274*a9b77d89SMarek Benc         {
275*a9b77d89SMarek Benc             skip("Failed to get device context\n");
276*a9b77d89SMarek Benc 
277*a9b77d89SMarek Benc             FsmState = FSM_STATE_END;
278*a9b77d89SMarek Benc             DestroyWindow(Window);
279*a9b77d89SMarek Benc 
280*a9b77d89SMarek Benc             return 0;
281*a9b77d89SMarek Benc         }
282*a9b77d89SMarek Benc         Color = GetPixel(hdc, ClientWidth / 4, ClientHeight / 4);
283*a9b77d89SMarek Benc 
284*a9b77d89SMarek Benc         ReleaseDC(Window, hdc);
285*a9b77d89SMarek Benc         hdc = NULL;
286*a9b77d89SMarek Benc 
287*a9b77d89SMarek Benc         if (Color == CLR_INVALID)
288*a9b77d89SMarek Benc         {
289*a9b77d89SMarek Benc             skip("Failed to get window color\n");
290*a9b77d89SMarek Benc 
291*a9b77d89SMarek Benc             FsmState = FSM_STATE_END;
292*a9b77d89SMarek Benc             DestroyWindow(Window);
293*a9b77d89SMarek Benc 
294*a9b77d89SMarek Benc             return 0;
295*a9b77d89SMarek Benc         }
296*a9b77d89SMarek Benc     }
297*a9b77d89SMarek Benc 
298*a9b77d89SMarek Benc     trace("FsmState: %d, Color: 0x%.8lX\n", FsmState, Color);
299*a9b77d89SMarek Benc 
300*a9b77d89SMarek Benc     switch (FsmState)
301*a9b77d89SMarek Benc     {
302*a9b77d89SMarek Benc         case FSM_STATE_START:
303*a9b77d89SMarek Benc             ShowVertScrollBar(Window);
304*a9b77d89SMarek Benc             FsmState = FSM_STATE_VSCR_SHOWN;
305*a9b77d89SMarek Benc             break;
306*a9b77d89SMarek Benc 
307*a9b77d89SMarek Benc         case FSM_STATE_VSCR_SHOWN:
308*a9b77d89SMarek Benc             if (HaveHRedraw)
309*a9b77d89SMarek Benc             {
310*a9b77d89SMarek Benc                 ok(Color != PrevColor,
311*a9b77d89SMarek Benc                    "CS_HREDRAW specified, but appearence of vertical scroll bar"
312*a9b77d89SMarek Benc                    " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
313*a9b77d89SMarek Benc                    PrevColor, Color);
314*a9b77d89SMarek Benc             }
315*a9b77d89SMarek Benc             else
316*a9b77d89SMarek Benc             {
317*a9b77d89SMarek Benc                 ok(Color == PrevColor,
318*a9b77d89SMarek Benc                    "CS_HREDRAW not specified, but appearence of vertical scroll bar"
319*a9b77d89SMarek Benc                    " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
320*a9b77d89SMarek Benc                    PrevColor, Color);
321*a9b77d89SMarek Benc             }
322*a9b77d89SMarek Benc 
323*a9b77d89SMarek Benc             HideVertScrollBar(Window);
324*a9b77d89SMarek Benc             FsmState = FSM_STATE_VSCR_HIDDEN;
325*a9b77d89SMarek Benc             break;
326*a9b77d89SMarek Benc 
327*a9b77d89SMarek Benc         case FSM_STATE_VSCR_HIDDEN:
328*a9b77d89SMarek Benc             if (HaveHRedraw)
329*a9b77d89SMarek Benc             {
330*a9b77d89SMarek Benc                 ok(Color != PrevColor,
331*a9b77d89SMarek Benc                    "CS_HREDRAW specified, but disappearence of vertical scroll bar"
332*a9b77d89SMarek Benc                    " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
333*a9b77d89SMarek Benc                    PrevColor, Color);
334*a9b77d89SMarek Benc             }
335*a9b77d89SMarek Benc             else
336*a9b77d89SMarek Benc             {
337*a9b77d89SMarek Benc                 ok(Color == PrevColor,
338*a9b77d89SMarek Benc                    "CS_HREDRAW not specified, but disappearence of vertical scroll bar"
339*a9b77d89SMarek Benc                    " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
340*a9b77d89SMarek Benc                    PrevColor, Color);
341*a9b77d89SMarek Benc             }
342*a9b77d89SMarek Benc 
343*a9b77d89SMarek Benc             ShowHorzScrollBar(Window);
344*a9b77d89SMarek Benc             FsmState = FSM_STATE_HSCR_SHOWN;
345*a9b77d89SMarek Benc             break;
346*a9b77d89SMarek Benc 
347*a9b77d89SMarek Benc         case FSM_STATE_HSCR_SHOWN:
348*a9b77d89SMarek Benc             if (HaveVRedraw)
349*a9b77d89SMarek Benc             {
350*a9b77d89SMarek Benc                 ok(Color != PrevColor,
351*a9b77d89SMarek Benc                    "CS_VREDRAW specified, but appearence of horizontal scroll bar"
352*a9b77d89SMarek Benc                    " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
353*a9b77d89SMarek Benc                    PrevColor, Color);
354*a9b77d89SMarek Benc             }
355*a9b77d89SMarek Benc             else
356*a9b77d89SMarek Benc             {
357*a9b77d89SMarek Benc                 ok(Color == PrevColor,
358*a9b77d89SMarek Benc                    "CS_VREDRAW not specified, but appearence of horizontal scroll bar"
359*a9b77d89SMarek Benc                    " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
360*a9b77d89SMarek Benc                    PrevColor, Color);
361*a9b77d89SMarek Benc             }
362*a9b77d89SMarek Benc 
363*a9b77d89SMarek Benc             HideHorzScrollBar(Window);
364*a9b77d89SMarek Benc             FsmState = FSM_STATE_HSCR_HIDDEN;
365*a9b77d89SMarek Benc             break;
366*a9b77d89SMarek Benc 
367*a9b77d89SMarek Benc         case FSM_STATE_HSCR_HIDDEN:
368*a9b77d89SMarek Benc             if (HaveVRedraw)
369*a9b77d89SMarek Benc             {
370*a9b77d89SMarek Benc                 ok(Color != PrevColor,
371*a9b77d89SMarek Benc                    "CS_VREDRAW specified, but disappearence of horizontal scroll bar"
372*a9b77d89SMarek Benc                    " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
373*a9b77d89SMarek Benc                    PrevColor, Color);
374*a9b77d89SMarek Benc             }
375*a9b77d89SMarek Benc             else
376*a9b77d89SMarek Benc             {
377*a9b77d89SMarek Benc                 ok(Color == PrevColor,
378*a9b77d89SMarek Benc                    "CS_VREDRAW not specified, but disappearence of horizontal scroll bar"
379*a9b77d89SMarek Benc                    " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
380*a9b77d89SMarek Benc                    PrevColor, Color);
381*a9b77d89SMarek Benc             }
382*a9b77d89SMarek Benc 
383*a9b77d89SMarek Benc             ShowVertScrollBar(Window);
384*a9b77d89SMarek Benc             ShowHorzScrollBar(Window);
385*a9b77d89SMarek Benc 
386*a9b77d89SMarek Benc             FsmState = FSM_STATE_BSCR_SHOWN;
387*a9b77d89SMarek Benc             break;
388*a9b77d89SMarek Benc 
389*a9b77d89SMarek Benc         case FSM_STATE_BSCR_SHOWN:
390*a9b77d89SMarek Benc             if (HaveHRedraw || HaveVRedraw)
391*a9b77d89SMarek Benc             {
392*a9b77d89SMarek Benc                 ok(Color != PrevColor,
393*a9b77d89SMarek Benc                    "CS_HREDRAW or CS_VREDRAW specified, but appearence of both scroll bars"
394*a9b77d89SMarek Benc                    " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
395*a9b77d89SMarek Benc                    PrevColor, Color);
396*a9b77d89SMarek Benc             }
397*a9b77d89SMarek Benc             else
398*a9b77d89SMarek Benc             {
399*a9b77d89SMarek Benc                 ok(Color == PrevColor,
400*a9b77d89SMarek Benc                    "Neither CS_HREDRAW nor CS_VREDRAW specified, but appearence"
401*a9b77d89SMarek Benc                    " of both scroll bars triggered unneccessary redraw,"
402*a9b77d89SMarek Benc                    " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
403*a9b77d89SMarek Benc                    PrevColor, Color);
404*a9b77d89SMarek Benc             }
405*a9b77d89SMarek Benc 
406*a9b77d89SMarek Benc             HideVertScrollBar(Window);
407*a9b77d89SMarek Benc             HideHorzScrollBar(Window);
408*a9b77d89SMarek Benc 
409*a9b77d89SMarek Benc             FsmState = FSM_STATE_BSCR_HIDDEN;
410*a9b77d89SMarek Benc             break;
411*a9b77d89SMarek Benc 
412*a9b77d89SMarek Benc         case FSM_STATE_BSCR_HIDDEN:
413*a9b77d89SMarek Benc             if (HaveHRedraw || HaveVRedraw)
414*a9b77d89SMarek Benc             {
415*a9b77d89SMarek Benc                 ok(Color != PrevColor,
416*a9b77d89SMarek Benc                    "CS_HREDRAW or CS_VREDRAW specified, but disappearence of both scroll bars"
417*a9b77d89SMarek Benc                    " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
418*a9b77d89SMarek Benc                    PrevColor, Color);
419*a9b77d89SMarek Benc             }
420*a9b77d89SMarek Benc             else
421*a9b77d89SMarek Benc             {
422*a9b77d89SMarek Benc                 ok(Color == PrevColor,
423*a9b77d89SMarek Benc                    "Neither CS_HREDRAW nor CS_VREDRAW specified, but disappearence"
424*a9b77d89SMarek Benc                    " of both scroll bars triggered unneccessary redraw,"
425*a9b77d89SMarek Benc                    " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
426*a9b77d89SMarek Benc                    PrevColor, Color);
427*a9b77d89SMarek Benc             }
428*a9b77d89SMarek Benc 
429*a9b77d89SMarek Benc             SetWindowPos(Window, HWND_TOPMOST, 0, 0, SmallWidth, OrigHeight, SWP_NOMOVE);
430*a9b77d89SMarek Benc             FsmState = FSM_STATE_WIDTH_SHRUNK;
431*a9b77d89SMarek Benc             break;
432*a9b77d89SMarek Benc 
433*a9b77d89SMarek Benc         case FSM_STATE_WIDTH_SHRUNK:
434*a9b77d89SMarek Benc             if (HaveHRedraw)
435*a9b77d89SMarek Benc             {
436*a9b77d89SMarek Benc                 ok(Color != PrevColor,
437*a9b77d89SMarek Benc                    "CS_HREDRAW specified, but horizontal window shrinkage"
438*a9b77d89SMarek Benc                    " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
439*a9b77d89SMarek Benc                    PrevColor, Color);
440*a9b77d89SMarek Benc             }
441*a9b77d89SMarek Benc             else
442*a9b77d89SMarek Benc             {
443*a9b77d89SMarek Benc                 ok(Color == PrevColor,
444*a9b77d89SMarek Benc                    "CS_HREDRAW not specified, but horizontal window shrinkage"
445*a9b77d89SMarek Benc                    " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
446*a9b77d89SMarek Benc                    PrevColor, Color);
447*a9b77d89SMarek Benc             }
448*a9b77d89SMarek Benc 
449*a9b77d89SMarek Benc             SetWindowPos(Window, HWND_TOPMOST, 0, 0, OrigWidth, OrigHeight, SWP_NOMOVE);
450*a9b77d89SMarek Benc             FsmState = FSM_STATE_WIDTH_EXPANDED;
451*a9b77d89SMarek Benc             break;
452*a9b77d89SMarek Benc 
453*a9b77d89SMarek Benc         case FSM_STATE_WIDTH_EXPANDED:
454*a9b77d89SMarek Benc             if (HaveHRedraw)
455*a9b77d89SMarek Benc             {
456*a9b77d89SMarek Benc                 ok(Color != PrevColor,
457*a9b77d89SMarek Benc                    "CS_HREDRAW specified, but horizontal window expansion"
458*a9b77d89SMarek Benc                    " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
459*a9b77d89SMarek Benc                    PrevColor, Color);
460*a9b77d89SMarek Benc             }
461*a9b77d89SMarek Benc             else
462*a9b77d89SMarek Benc             {
463*a9b77d89SMarek Benc                 ok(Color == PrevColor,
464*a9b77d89SMarek Benc                    "CS_HREDRAW not specified, but horizontal window expansion"
465*a9b77d89SMarek Benc                    " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
466*a9b77d89SMarek Benc                    PrevColor, Color);
467*a9b77d89SMarek Benc             }
468*a9b77d89SMarek Benc 
469*a9b77d89SMarek Benc             SetWindowPos(Window, HWND_TOPMOST, 0, 0, OrigWidth, SmallHeight, SWP_NOMOVE);
470*a9b77d89SMarek Benc             FsmState = FSM_STATE_HEIGHT_SHRUNK;
471*a9b77d89SMarek Benc             break;
472*a9b77d89SMarek Benc 
473*a9b77d89SMarek Benc         case FSM_STATE_HEIGHT_SHRUNK:
474*a9b77d89SMarek Benc             if (HaveVRedraw)
475*a9b77d89SMarek Benc             {
476*a9b77d89SMarek Benc                 ok(Color != PrevColor,
477*a9b77d89SMarek Benc                    "CS_VREDRAW specified, but vertical window shrinkage"
478*a9b77d89SMarek Benc                    " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
479*a9b77d89SMarek Benc                    PrevColor, Color);
480*a9b77d89SMarek Benc             }
481*a9b77d89SMarek Benc             else
482*a9b77d89SMarek Benc             {
483*a9b77d89SMarek Benc                 ok(Color == PrevColor,
484*a9b77d89SMarek Benc                    "CS_VREDRAW not specified, but vertical window shrinkage"
485*a9b77d89SMarek Benc                    " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
486*a9b77d89SMarek Benc                    PrevColor, Color);
487*a9b77d89SMarek Benc             }
488*a9b77d89SMarek Benc 
489*a9b77d89SMarek Benc             SetWindowPos(Window, HWND_TOPMOST, 0, 0, OrigWidth, OrigHeight, SWP_NOMOVE);
490*a9b77d89SMarek Benc             FsmState = FSM_STATE_HEIGHT_EXPANDED;
491*a9b77d89SMarek Benc             break;
492*a9b77d89SMarek Benc 
493*a9b77d89SMarek Benc         case FSM_STATE_HEIGHT_EXPANDED:
494*a9b77d89SMarek Benc             if (HaveVRedraw)
495*a9b77d89SMarek Benc             {
496*a9b77d89SMarek Benc                 ok(Color != PrevColor,
497*a9b77d89SMarek Benc                    "CS_VREDRAW specified, but vertical window expansion"
498*a9b77d89SMarek Benc                    " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
499*a9b77d89SMarek Benc                    PrevColor, Color);
500*a9b77d89SMarek Benc             }
501*a9b77d89SMarek Benc             else
502*a9b77d89SMarek Benc             {
503*a9b77d89SMarek Benc                 ok(Color == PrevColor,
504*a9b77d89SMarek Benc                    "CS_VREDRAW not specified, but vertical window expansion"
505*a9b77d89SMarek Benc                    " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
506*a9b77d89SMarek Benc                    PrevColor, Color);
507*a9b77d89SMarek Benc             }
508*a9b77d89SMarek Benc 
509*a9b77d89SMarek Benc             SetWindowPos(Window, HWND_TOPMOST, 0, 0, SmallWidth, SmallHeight, SWP_NOMOVE);
510*a9b77d89SMarek Benc 
511*a9b77d89SMarek Benc             FsmState = FSM_STATE_BOTH_SHRUNK;
512*a9b77d89SMarek Benc             break;
513*a9b77d89SMarek Benc 
514*a9b77d89SMarek Benc         case FSM_STATE_BOTH_SHRUNK:
515*a9b77d89SMarek Benc             if (HaveHRedraw || HaveVRedraw)
516*a9b77d89SMarek Benc             {
517*a9b77d89SMarek Benc                 ok(Color != PrevColor,
518*a9b77d89SMarek Benc                    "CS_HREDRAW or CS_VREDRAW specified, but combined"
519*a9b77d89SMarek Benc                    " vertical/horizontal shrinkage didn't trigger redraw,"
520*a9b77d89SMarek Benc                    " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
521*a9b77d89SMarek Benc                    PrevColor, Color);
522*a9b77d89SMarek Benc             }
523*a9b77d89SMarek Benc             else
524*a9b77d89SMarek Benc             {
525*a9b77d89SMarek Benc                 ok(Color == PrevColor,
526*a9b77d89SMarek Benc                    "Neither CS_HREDRAW nor CS_VREDRAW specified, but combined"
527*a9b77d89SMarek Benc                    " vertical/horizontal shrinkage triggered unneccessary redraw,"
528*a9b77d89SMarek Benc                    " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
529*a9b77d89SMarek Benc                    PrevColor, Color);
530*a9b77d89SMarek Benc             }
531*a9b77d89SMarek Benc 
532*a9b77d89SMarek Benc             SetWindowPos(Window, HWND_TOPMOST, 0, 0, OrigWidth, OrigHeight, SWP_NOMOVE);
533*a9b77d89SMarek Benc 
534*a9b77d89SMarek Benc             FsmState = FSM_STATE_BOTH_EXPANDED;
535*a9b77d89SMarek Benc             break;
536*a9b77d89SMarek Benc 
537*a9b77d89SMarek Benc         case FSM_STATE_BOTH_EXPANDED:
538*a9b77d89SMarek Benc             if (HaveHRedraw || HaveVRedraw)
539*a9b77d89SMarek Benc             {
540*a9b77d89SMarek Benc                 ok(Color != PrevColor,
541*a9b77d89SMarek Benc                    "CS_HREDRAW or CS_VREDRAW specified, but combined"
542*a9b77d89SMarek Benc                    " vertical/horizontal expansion didn't trigger redraw,"
543*a9b77d89SMarek Benc                    " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
544*a9b77d89SMarek Benc                    PrevColor, Color);
545*a9b77d89SMarek Benc             }
546*a9b77d89SMarek Benc             else
547*a9b77d89SMarek Benc             {
548*a9b77d89SMarek Benc                 ok(Color == PrevColor,
549*a9b77d89SMarek Benc                    "Neither CS_HREDRAW nor CS_VREDRAW specified, but combined"
550*a9b77d89SMarek Benc                    " vertical/horizontal expansion triggered unneccessary redraw,"
551*a9b77d89SMarek Benc                    " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
552*a9b77d89SMarek Benc                    PrevColor, Color);
553*a9b77d89SMarek Benc             }
554*a9b77d89SMarek Benc 
555*a9b77d89SMarek Benc             FsmState = FSM_STATE_END;
556*a9b77d89SMarek Benc             DestroyWindow(Window);
557*a9b77d89SMarek Benc             break;
558*a9b77d89SMarek Benc 
559*a9b77d89SMarek Benc         case FSM_STATE_END:
560*a9b77d89SMarek Benc             break;
561*a9b77d89SMarek Benc     }
562*a9b77d89SMarek Benc 
563*a9b77d89SMarek Benc     PrevColor = Color;
564*a9b77d89SMarek Benc     return 0;
565*a9b77d89SMarek Benc }
566*a9b77d89SMarek Benc 
OnPaint(HWND Window)567*a9b77d89SMarek Benc static int OnPaint(HWND Window)
568*a9b77d89SMarek Benc {
569*a9b77d89SMarek Benc     HRGN Region;
570*a9b77d89SMarek Benc     HDC hdc;
571*a9b77d89SMarek Benc     PAINTSTRUCT ps;
572*a9b77d89SMarek Benc 
573*a9b77d89SMarek Benc     hdc = BeginPaint(Window, &ps);
574*a9b77d89SMarek Benc     if (hdc == NULL)
575*a9b77d89SMarek Benc     {
576*a9b77d89SMarek Benc         skip("Failed to get device context\n");
577*a9b77d89SMarek Benc         DestroyWindow(Window);
578*a9b77d89SMarek Benc         return 0;
579*a9b77d89SMarek Benc     }
580*a9b77d89SMarek Benc 
581*a9b77d89SMarek Benc     Region = CreateRectRgn(ps.rcPaint.left,
582*a9b77d89SMarek Benc                            ps.rcPaint.top,
583*a9b77d89SMarek Benc                            ps.rcPaint.right,
584*a9b77d89SMarek Benc                            ps.rcPaint.bottom);
585*a9b77d89SMarek Benc     if (Region == NULL)
586*a9b77d89SMarek Benc     {
587*a9b77d89SMarek Benc         skip("Failed to create drawing region\n");
588*a9b77d89SMarek Benc         EndPaint(Window, &ps);
589*a9b77d89SMarek Benc         DestroyWindow(Window);
590*a9b77d89SMarek Benc         return 0;
591*a9b77d89SMarek Benc     }
592*a9b77d89SMarek Benc 
593*a9b77d89SMarek Benc     if (!FillRgn(hdc, Region, ColorBrushes[CurrentColor]))
594*a9b77d89SMarek Benc     {
595*a9b77d89SMarek Benc         skip("Failed to paint the window\n");
596*a9b77d89SMarek Benc         DeleteObject(Region);
597*a9b77d89SMarek Benc         EndPaint(Window, &ps);
598*a9b77d89SMarek Benc         DestroyWindow(Window);
599*a9b77d89SMarek Benc         return 0;
600*a9b77d89SMarek Benc     }
601*a9b77d89SMarek Benc 
602*a9b77d89SMarek Benc     DeleteObject(Region);
603*a9b77d89SMarek Benc     EndPaint(Window, &ps);
604*a9b77d89SMarek Benc 
605*a9b77d89SMarek Benc     return 0;
606*a9b77d89SMarek Benc }
607*a9b77d89SMarek Benc 
WindowProc(HWND Window,UINT Message,WPARAM wParam,LPARAM lParam)608*a9b77d89SMarek Benc static LRESULT CALLBACK WindowProc(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam)
609*a9b77d89SMarek Benc {
610*a9b77d89SMarek Benc     switch (Message)
611*a9b77d89SMarek Benc     {
612*a9b77d89SMarek Benc         case WM_CREATE:
613*a9b77d89SMarek Benc         {
614*a9b77d89SMarek Benc             RECT Rect;
615*a9b77d89SMarek Benc             WindowCreatedOk = FALSE;
616*a9b77d89SMarek Benc 
617*a9b77d89SMarek Benc             /* It's important for the test that the entire Window is visible. */
618*a9b77d89SMarek Benc             if (!SetWindowPos(Window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE))
619*a9b77d89SMarek Benc             {
620*a9b77d89SMarek Benc                 skip("Failed to set window as top-most, code: %ld\n", GetLastError());
621*a9b77d89SMarek Benc                 return -1;
622*a9b77d89SMarek Benc             }
623*a9b77d89SMarek Benc 
624*a9b77d89SMarek Benc             if (!GetClientRect(Window, &Rect))
625*a9b77d89SMarek Benc             {
626*a9b77d89SMarek Benc                 skip("Failed to retrieve client area dimensions, code: %ld\n", GetLastError());
627*a9b77d89SMarek Benc                 return -1;
628*a9b77d89SMarek Benc             }
629*a9b77d89SMarek Benc             ClientWidth = Rect.right;
630*a9b77d89SMarek Benc             ClientHeight = Rect.bottom;
631*a9b77d89SMarek Benc 
632*a9b77d89SMarek Benc             if (!GetWindowRect(Window, &Rect))
633*a9b77d89SMarek Benc             {
634*a9b77d89SMarek Benc                 skip("Failed to retrieve window dimensions, code: %ld\n", GetLastError());
635*a9b77d89SMarek Benc                 return -1;
636*a9b77d89SMarek Benc             }
637*a9b77d89SMarek Benc             OrigWidth  = Rect.right - Rect.left;
638*a9b77d89SMarek Benc             OrigHeight = Rect.bottom - Rect.top;
639*a9b77d89SMarek Benc 
640*a9b77d89SMarek Benc             SmallWidth  = max((OrigWidth  * 3) / 4, 1);
641*a9b77d89SMarek Benc             SmallHeight = max((OrigHeight * 3) / 4, 1);
642*a9b77d89SMarek Benc             OrigWidth   = max(OrigWidth,  SmallWidth  + 1);
643*a9b77d89SMarek Benc             OrigHeight  = max(OrigHeight, SmallHeight + 1);
644*a9b77d89SMarek Benc 
645*a9b77d89SMarek Benc             trace("OrigWidth: %d, OrigHeight: %d, SmallWidth: %d, SmallHeight: %d\n",
646*a9b77d89SMarek Benc                   OrigWidth, OrigHeight, SmallWidth, SmallHeight);
647*a9b77d89SMarek Benc 
648*a9b77d89SMarek Benc             HideVertScrollBar(Window);
649*a9b77d89SMarek Benc             HideHorzScrollBar(Window);
650*a9b77d89SMarek Benc 
651*a9b77d89SMarek Benc             FsmState = FSM_STATE_START;
652*a9b77d89SMarek Benc             FsmTimer = 0;
653*a9b77d89SMarek Benc             WindowCreatedOk = TRUE;
654*a9b77d89SMarek Benc             return 0;
655*a9b77d89SMarek Benc         }
656*a9b77d89SMarek Benc 
657*a9b77d89SMarek Benc         case WM_PAINT:
658*a9b77d89SMarek Benc             if (FsmTimer == 0 && WindowCreatedOk)
659*a9b77d89SMarek Benc             {
660*a9b77d89SMarek Benc                 FsmTimer = SetTimer(Window, 1, FSM_STEP_PERIOD_MS, NULL);
661*a9b77d89SMarek Benc                 if (FsmTimer == 0)
662*a9b77d89SMarek Benc                 {
663*a9b77d89SMarek Benc                     skip("Failed to initialize FSM timer, code: %ld\n", GetLastError());
664*a9b77d89SMarek Benc                     WindowCreatedOk = FALSE;
665*a9b77d89SMarek Benc                     DestroyWindow(Window);
666*a9b77d89SMarek Benc                     return 0;
667*a9b77d89SMarek Benc                 }
668*a9b77d89SMarek Benc             }
669*a9b77d89SMarek Benc             return OnPaint(Window);
670*a9b77d89SMarek Benc 
671*a9b77d89SMarek Benc         case WM_SIZE:
672*a9b77d89SMarek Benc         {
673*a9b77d89SMarek Benc             int NewWidth = LOWORD(lParam);
674*a9b77d89SMarek Benc             int NewHeight = HIWORD(lParam);
675*a9b77d89SMarek Benc 
676*a9b77d89SMarek Benc             if (NewWidth != 0 && NewHeight != 0 &&
677*a9b77d89SMarek Benc                 (NewWidth != ClientWidth || NewHeight != ClientHeight))
678*a9b77d89SMarek Benc             {
679*a9b77d89SMarek Benc                 CurrentColor = (CurrentColor + 1) % TEST_COLOR_COUNT;
680*a9b77d89SMarek Benc                 SetClassLongPtrW(Window,
681*a9b77d89SMarek Benc                                  GCLP_HBRBACKGROUND,
682*a9b77d89SMarek Benc                                  (LONG_PTR)ColorBrushes[CurrentColor]);
683*a9b77d89SMarek Benc 
684*a9b77d89SMarek Benc                 trace("New window size: %d x %d, new color: 0x%.8lX\n",
685*a9b77d89SMarek Benc                       NewWidth, NewHeight, Colors[CurrentColor]);
686*a9b77d89SMarek Benc 
687*a9b77d89SMarek Benc                 ClientWidth = NewWidth;
688*a9b77d89SMarek Benc                 ClientHeight = NewHeight;
689*a9b77d89SMarek Benc             }
690*a9b77d89SMarek Benc             return 0;
691*a9b77d89SMarek Benc         }
692*a9b77d89SMarek Benc 
693*a9b77d89SMarek Benc         case WM_ERASEBKGND:
694*a9b77d89SMarek Benc             /* We use WM_PAINT instead, since WM_ERASEBKGND is issued before WM_SIZE. */
695*a9b77d89SMarek Benc             return 1;
696*a9b77d89SMarek Benc 
697*a9b77d89SMarek Benc         case WM_TIMER:
698*a9b77d89SMarek Benc             if (wParam != 0 && wParam == FsmTimer)
699*a9b77d89SMarek Benc             {
700*a9b77d89SMarek Benc                 return FsmStep(Window);
701*a9b77d89SMarek Benc             }
702*a9b77d89SMarek Benc             break;
703*a9b77d89SMarek Benc 
704*a9b77d89SMarek Benc         case WM_NCDESTROY:
705*a9b77d89SMarek Benc             if (FsmTimer != 0)
706*a9b77d89SMarek Benc             {
707*a9b77d89SMarek Benc                 KillTimer(Window, FsmTimer);
708*a9b77d89SMarek Benc                 FsmTimer = 0;
709*a9b77d89SMarek Benc 
710*a9b77d89SMarek Benc                 if (FsmState != FSM_STATE_END)
711*a9b77d89SMarek Benc                 {
712*a9b77d89SMarek Benc                     skip("Window closed before test concluded, FsmState: %d, FSM_STATE_END: %d.\n",
713*a9b77d89SMarek Benc                          FsmState, FSM_STATE_END);
714*a9b77d89SMarek Benc                 }
715*a9b77d89SMarek Benc             }
716*a9b77d89SMarek Benc             else if (WindowCreatedOk)
717*a9b77d89SMarek Benc             {
718*a9b77d89SMarek Benc                 skip("Window closed before test began.\n");
719*a9b77d89SMarek Benc             }
720*a9b77d89SMarek Benc             return 0;
721*a9b77d89SMarek Benc 
722*a9b77d89SMarek Benc         case WM_DESTROY:
723*a9b77d89SMarek Benc             PostQuitMessage(0);
724*a9b77d89SMarek Benc             return 0;
725*a9b77d89SMarek Benc     }
726*a9b77d89SMarek Benc     return DefWindowProcW(Window, Message, wParam, lParam);
727*a9b77d89SMarek Benc }
728