ReactOS 0.4.16-dev-297-gc569aee
ScrollBarRedraw.c File Reference
#include "precomp.h"
Include dependency graph for ScrollBarRedraw.c:

Go to the source code of this file.

Macros

#define TEST_CLASS_NAME   L"ScrollBarRedraw"
 
#define TEST_WINDOW_TITLE   L"ScrollBarRedraw"
 
#define TEST_COLOR_COUNT   16
 
#define FSM_STEP_PERIOD_MS   250
 

Typedefs

typedef enum _FSM_STATE FSM_STATE
 

Enumerations

enum  _FSM_STATE {
  FSM_STATE_START , FSM_STATE_VSCR_SHOWN , FSM_STATE_VSCR_HIDDEN , FSM_STATE_HSCR_SHOWN ,
  FSM_STATE_HSCR_HIDDEN , FSM_STATE_BSCR_SHOWN , FSM_STATE_BSCR_HIDDEN , FSM_STATE_WIDTH_SHRUNK ,
  FSM_STATE_WIDTH_EXPANDED , FSM_STATE_HEIGHT_SHRUNK , FSM_STATE_HEIGHT_EXPANDED , FSM_STATE_BOTH_SHRUNK ,
  FSM_STATE_BOTH_EXPANDED , FSM_STATE_END
}
 

Functions

static LRESULT CALLBACK WindowProc (HWND Window, UINT Message, WPARAM wParam, LPARAM lParam)
 
static void ColorsCleanup (void)
 
static BOOL ColorsInit (void)
 
static void RunTestWindow (PCWSTR ClassName, PCWSTR WindowTitle, UINT ClassStyle)
 
 START_TEST (ScrollBarRedraw)
 
static void HideVertScrollBar (HWND Window)
 
static void ShowVertScrollBar (HWND Window)
 
static void HideHorzScrollBar (HWND Window)
 
static void ShowHorzScrollBar (HWND Window)
 
static int FsmStep (HWND Window)
 
static int OnPaint (HWND Window)
 

Variables

static COLORREF Colors []
 
static HBRUSH ColorBrushes [TEST_COLOR_COUNT] = { 0 }
 
static BOOL HaveHRedraw = FALSE
 
static BOOL HaveVRedraw = FALSE
 
static BOOL WindowCreatedOk = FALSE
 
static UINT_PTR FsmTimer = 0
 
static UINT CurrentColor = 0
 
static FSM_STATE FsmState = FSM_STATE_START
 
static int ClientWidth = 0
 
static int ClientHeight = 0
 
static int OrigWidth = 0
 
static int OrigHeight = 0
 
static int SmallWidth = 0
 
static int SmallHeight = 0
 

Macro Definition Documentation

◆ FSM_STEP_PERIOD_MS

#define FSM_STEP_PERIOD_MS   250

Definition at line 61 of file ScrollBarRedraw.c.

◆ TEST_CLASS_NAME

#define TEST_CLASS_NAME   L"ScrollBarRedraw"

Definition at line 10 of file ScrollBarRedraw.c.

◆ TEST_COLOR_COUNT

#define TEST_COLOR_COUNT   16

Definition at line 15 of file ScrollBarRedraw.c.

◆ TEST_WINDOW_TITLE

#define TEST_WINDOW_TITLE   L"ScrollBarRedraw"

Definition at line 11 of file ScrollBarRedraw.c.

Typedef Documentation

◆ FSM_STATE

Enumeration Type Documentation

◆ _FSM_STATE

Enumerator
FSM_STATE_START 
FSM_STATE_VSCR_SHOWN 
FSM_STATE_VSCR_HIDDEN 
FSM_STATE_HSCR_SHOWN 
FSM_STATE_HSCR_HIDDEN 
FSM_STATE_BSCR_SHOWN 
FSM_STATE_BSCR_HIDDEN 
FSM_STATE_WIDTH_SHRUNK 
FSM_STATE_WIDTH_EXPANDED 
FSM_STATE_HEIGHT_SHRUNK 
FSM_STATE_HEIGHT_EXPANDED 
FSM_STATE_BOTH_SHRUNK 
FSM_STATE_BOTH_EXPANDED 
FSM_STATE_END 

Definition at line 43 of file ScrollBarRedraw.c.

44{
59} FSM_STATE;
@ FSM_STATE_BSCR_HIDDEN
@ FSM_STATE_BOTH_SHRUNK
@ FSM_STATE_HSCR_SHOWN
@ FSM_STATE_END
@ FSM_STATE_HEIGHT_SHRUNK
@ FSM_STATE_BSCR_SHOWN
@ FSM_STATE_HEIGHT_EXPANDED
@ FSM_STATE_VSCR_SHOWN
@ FSM_STATE_VSCR_HIDDEN
@ FSM_STATE_HSCR_HIDDEN
@ FSM_STATE_WIDTH_SHRUNK
@ FSM_STATE_BOTH_EXPANDED
@ FSM_STATE_START
@ FSM_STATE_WIDTH_EXPANDED
enum _FSM_STATE FSM_STATE

Function Documentation

◆ ColorsCleanup()

static void ColorsCleanup ( void  )
static

Definition at line 75 of file ScrollBarRedraw.c.

76{
77 UINT Iter;
78
79 for (Iter = 0; Iter < _countof(ColorBrushes); Iter++)
80 {
81 if (ColorBrushes[Iter] != NULL)
82 {
84 ColorBrushes[Iter] = NULL;
85 }
86 }
87}
static HBRUSH ColorBrushes[TEST_COLOR_COUNT]
#define NULL
Definition: types.h:112
pKey DeleteObject()
unsigned int UINT
Definition: ndis.h:50
#define _countof(array)
Definition: sndvol32.h:70

Referenced by ColorsInit(), and START_TEST().

◆ ColorsInit()

static BOOL ColorsInit ( void  )
static

Definition at line 89 of file ScrollBarRedraw.c.

90{
91 UINT Iter;
92
94
95 for (Iter = 0; Iter < _countof(ColorBrushes); Iter++)
96 {
98 if (ColorBrushes[Iter] == NULL)
99 {
101 return FALSE;
102 }
103 }
104
105 return TRUE;
106}
static void ColorsCleanup(void)
Colors
Definition: ansiprsr.h:4
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define assert(x)
Definition: debug.h:53
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)

Referenced by START_TEST().

◆ FsmStep()

static int FsmStep ( HWND  Window)
static

Definition at line 264 of file ScrollBarRedraw.c.

265{
266 static COLORREF PrevColor = CLR_INVALID;
268 HDC hdc = NULL;
269
270 if (FsmState != FSM_STATE_END)
271 {
272 hdc = GetDC(Window);
273 if (hdc == NULL)
274 {
275 skip("Failed to get device context\n");
276
279
280 return 0;
281 }
283
285 hdc = NULL;
286
287 if (Color == CLR_INVALID)
288 {
289 skip("Failed to get window color\n");
290
293
294 return 0;
295 }
296 }
297
298 trace("FsmState: %d, Color: 0x%.8lX\n", FsmState, Color);
299
300 switch (FsmState)
301 {
302 case FSM_STATE_START:
305 break;
306
308 if (HaveHRedraw)
309 {
310 ok(Color != PrevColor,
311 "CS_HREDRAW specified, but appearence of vertical scroll bar"
312 " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
313 PrevColor, Color);
314 }
315 else
316 {
317 ok(Color == PrevColor,
318 "CS_HREDRAW not specified, but appearence of vertical scroll bar"
319 " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
320 PrevColor, Color);
321 }
322
325 break;
326
328 if (HaveHRedraw)
329 {
330 ok(Color != PrevColor,
331 "CS_HREDRAW specified, but disappearence of vertical scroll bar"
332 " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
333 PrevColor, Color);
334 }
335 else
336 {
337 ok(Color == PrevColor,
338 "CS_HREDRAW not specified, but disappearence of vertical scroll bar"
339 " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
340 PrevColor, Color);
341 }
342
345 break;
346
348 if (HaveVRedraw)
349 {
350 ok(Color != PrevColor,
351 "CS_VREDRAW specified, but appearence of horizontal scroll bar"
352 " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
353 PrevColor, Color);
354 }
355 else
356 {
357 ok(Color == PrevColor,
358 "CS_VREDRAW not specified, but appearence of horizontal scroll bar"
359 " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
360 PrevColor, Color);
361 }
362
365 break;
366
368 if (HaveVRedraw)
369 {
370 ok(Color != PrevColor,
371 "CS_VREDRAW specified, but disappearence of horizontal scroll bar"
372 " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
373 PrevColor, Color);
374 }
375 else
376 {
377 ok(Color == PrevColor,
378 "CS_VREDRAW not specified, but disappearence of horizontal scroll bar"
379 " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
380 PrevColor, Color);
381 }
382
385
387 break;
388
391 {
392 ok(Color != PrevColor,
393 "CS_HREDRAW or CS_VREDRAW specified, but appearence of both scroll bars"
394 " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
395 PrevColor, Color);
396 }
397 else
398 {
399 ok(Color == PrevColor,
400 "Neither CS_HREDRAW nor CS_VREDRAW specified, but appearence"
401 " of both scroll bars triggered unneccessary redraw,"
402 " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
403 PrevColor, Color);
404 }
405
408
410 break;
411
414 {
415 ok(Color != PrevColor,
416 "CS_HREDRAW or CS_VREDRAW specified, but disappearence of both scroll bars"
417 " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
418 PrevColor, Color);
419 }
420 else
421 {
422 ok(Color == PrevColor,
423 "Neither CS_HREDRAW nor CS_VREDRAW specified, but disappearence"
424 " of both scroll bars triggered unneccessary redraw,"
425 " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
426 PrevColor, Color);
427 }
428
431 break;
432
434 if (HaveHRedraw)
435 {
436 ok(Color != PrevColor,
437 "CS_HREDRAW specified, but horizontal window shrinkage"
438 " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
439 PrevColor, Color);
440 }
441 else
442 {
443 ok(Color == PrevColor,
444 "CS_HREDRAW not specified, but horizontal window shrinkage"
445 " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
446 PrevColor, Color);
447 }
448
451 break;
452
454 if (HaveHRedraw)
455 {
456 ok(Color != PrevColor,
457 "CS_HREDRAW specified, but horizontal window expansion"
458 " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
459 PrevColor, Color);
460 }
461 else
462 {
463 ok(Color == PrevColor,
464 "CS_HREDRAW not specified, but horizontal window expansion"
465 " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
466 PrevColor, Color);
467 }
468
471 break;
472
474 if (HaveVRedraw)
475 {
476 ok(Color != PrevColor,
477 "CS_VREDRAW specified, but vertical window shrinkage"
478 " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
479 PrevColor, Color);
480 }
481 else
482 {
483 ok(Color == PrevColor,
484 "CS_VREDRAW not specified, but vertical window shrinkage"
485 " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
486 PrevColor, Color);
487 }
488
491 break;
492
494 if (HaveVRedraw)
495 {
496 ok(Color != PrevColor,
497 "CS_VREDRAW specified, but vertical window expansion"
498 " didn't trigger redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
499 PrevColor, Color);
500 }
501 else
502 {
503 ok(Color == PrevColor,
504 "CS_VREDRAW not specified, but vertical window expansion"
505 " triggered unneccessary redraw, PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
506 PrevColor, Color);
507 }
508
510
512 break;
513
516 {
517 ok(Color != PrevColor,
518 "CS_HREDRAW or CS_VREDRAW specified, but combined"
519 " vertical/horizontal shrinkage didn't trigger redraw,"
520 " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
521 PrevColor, Color);
522 }
523 else
524 {
525 ok(Color == PrevColor,
526 "Neither CS_HREDRAW nor CS_VREDRAW specified, but combined"
527 " vertical/horizontal shrinkage triggered unneccessary redraw,"
528 " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
529 PrevColor, Color);
530 }
531
533
535 break;
536
539 {
540 ok(Color != PrevColor,
541 "CS_HREDRAW or CS_VREDRAW specified, but combined"
542 " vertical/horizontal expansion didn't trigger redraw,"
543 " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
544 PrevColor, Color);
545 }
546 else
547 {
548 ok(Color == PrevColor,
549 "Neither CS_HREDRAW nor CS_VREDRAW specified, but combined"
550 " vertical/horizontal expansion triggered unneccessary redraw,"
551 " PrevColor: 0x%.8lX, Color: 0x%.8lX\n",
552 PrevColor, Color);
553 }
554
557 break;
558
559 case FSM_STATE_END:
560 break;
561 }
562
563 PrevColor = Color;
564 return 0;
565}
static int SmallHeight
static FSM_STATE FsmState
static BOOL HaveHRedraw
static void HideHorzScrollBar(HWND Window)
static int SmallWidth
static void HideVertScrollBar(HWND Window)
static void ShowVertScrollBar(HWND Window)
static int ClientHeight
static int OrigHeight
static int OrigWidth
static void ShowHorzScrollBar(HWND Window)
static BOOL HaveVRedraw
static int ClientWidth
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
Definition: window.c:28
DWORD COLORREF
Definition: windef.h:300
#define CLR_INVALID
Definition: wingdi.h:883
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define HWND_TOPMOST
Definition: winuser.h:1211
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1247
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by WindowProc().

◆ HideHorzScrollBar()

static void HideHorzScrollBar ( HWND  Window)
static

Definition at line 234 of file ScrollBarRedraw.c.

235{
236 SCROLLINFO ScrollInfo;
237
238 ScrollInfo.cbSize = sizeof(ScrollInfo);
239 ScrollInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
240 ScrollInfo.nPage = ClientWidth;
241
242 ScrollInfo.nMin = 0;
243 ScrollInfo.nMax = ClientWidth - 1;
244 ScrollInfo.nPos = 0;
245
246 SetScrollInfo(Window, SB_HORZ, &ScrollInfo, TRUE);
247}
#define SIF_RANGE
Definition: winuser.h:1238
#define SIF_PAGE
Definition: winuser.h:1236
#define SIF_POS
Definition: winuser.h:1237
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define SB_HORZ
Definition: winuser.h:552

Referenced by FsmStep(), and WindowProc().

◆ HideVertScrollBar()

static void HideVertScrollBar ( HWND  Window)
static

Definition at line 204 of file ScrollBarRedraw.c.

205{
206 SCROLLINFO ScrollInfo;
207
208 ScrollInfo.cbSize = sizeof(ScrollInfo);
209 ScrollInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
210 ScrollInfo.nPage = ClientHeight;
211
212 ScrollInfo.nMin = 0;
213 ScrollInfo.nMax = ClientHeight - 1;
214 ScrollInfo.nPos = 0;
215
216 SetScrollInfo(Window, SB_VERT, &ScrollInfo, TRUE);
217}
#define SB_VERT
Definition: winuser.h:553

Referenced by FsmStep(), and WindowProc().

◆ OnPaint()

static int OnPaint ( HWND  Window)
static

Definition at line 567 of file ScrollBarRedraw.c.

568{
569 HRGN Region;
570 HDC hdc;
571 PAINTSTRUCT ps;
572
573 hdc = BeginPaint(Window, &ps);
574 if (hdc == NULL)
575 {
576 skip("Failed to get device context\n");
578 return 0;
579 }
580
582 ps.rcPaint.top,
583 ps.rcPaint.right,
584 ps.rcPaint.bottom);
585 if (Region == NULL)
586 {
587 skip("Failed to create drawing region\n");
588 EndPaint(Window, &ps);
590 return 0;
591 }
592
594 {
595 skip("Failed to paint the window\n");
597 EndPaint(Window, &ps);
599 return 0;
600 }
601
603 EndPaint(Window, &ps);
604
605 return 0;
606}
static UINT CurrentColor
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI FillRgn(_In_ HDC, _In_ HRGN, _In_ HBRUSH)
Definition: painting.c:183
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by WindowProc().

◆ RunTestWindow()

static void RunTestWindow ( PCWSTR  ClassName,
PCWSTR  WindowTitle,
UINT  ClassStyle 
)
static

Definition at line 108 of file ScrollBarRedraw.c.

109{
110 WNDCLASSW Class = { 0 };
111 HWND Window;
112 MSG Message;
114
115 CurrentColor = 0;
117
118 Class.style = ClassStyle;
119 Class.lpfnWndProc = WindowProc;
120 Class.cbClsExtra = 0;
121 Class.cbWndExtra = 0;
122 Class.hInstance = hInst;
124 Class.hCursor = LoadCursor(NULL, IDC_ARROW);
125 Class.hbrBackground = ColorBrushes[CurrentColor];
126 Class.lpszMenuName = NULL;
127 Class.lpszClassName = ClassName;
128
129 if (!RegisterClassW(&Class))
130 {
131 skip("Failed to register window class '%ls', code: %ld\n",
132 ClassName, GetLastError());
133 return;
134 }
135
136 Window = CreateWindowW(ClassName,
137 WindowTitle,
143 NULL,
144 NULL,
145 hInst,
146 NULL);
147 if (Window == NULL)
148 {
149 skip("Failed to create window of class '%ls', code: %ld\n",
150 ClassName, GetLastError());
151 return;
152 }
153
156
157 while (GetMessageW(&Message, NULL, 0, 0))
158 {
161 }
162}
static LRESULT CALLBACK WindowProc(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam)
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static const WCHAR Message[]
Definition: register.c:74
HINSTANCE hInst
Definition: dxdiag.c:13
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SW_SHOWNORMAL
Definition: winuser.h:773
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
#define IDI_APPLICATION
Definition: winuser.h:704
#define LoadIcon
Definition: winuser.h:5825
BOOL WINAPI UpdateWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5824
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4319
#define CW_USEDEFAULT
Definition: winuser.h:225
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)

Referenced by START_TEST().

◆ ShowHorzScrollBar()

static void ShowHorzScrollBar ( HWND  Window)
static

Definition at line 249 of file ScrollBarRedraw.c.

250{
251 SCROLLINFO ScrollInfo;
252
253 ScrollInfo.cbSize = sizeof(ScrollInfo);
254 ScrollInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
255 ScrollInfo.nPage = ClientWidth;
256
257 ScrollInfo.nMin = 0;
258 ScrollInfo.nMax = (3 * ClientWidth) - 1;
259 ScrollInfo.nPos = 0;
260
261 SetScrollInfo(Window, SB_HORZ, &ScrollInfo, TRUE);
262}

Referenced by FsmStep().

◆ ShowVertScrollBar()

static void ShowVertScrollBar ( HWND  Window)
static

Definition at line 219 of file ScrollBarRedraw.c.

220{
221 SCROLLINFO ScrollInfo;
222
223 ScrollInfo.cbSize = sizeof(ScrollInfo);
224 ScrollInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
225 ScrollInfo.nPage = ClientHeight;
226
227 ScrollInfo.nMin = 0;
228 ScrollInfo.nMax = (3 * ClientHeight) - 1;
229 ScrollInfo.nPos = 0;
230
231 SetScrollInfo(Window, SB_VERT, &ScrollInfo, TRUE);
232}

Referenced by FsmStep().

◆ START_TEST()

START_TEST ( ScrollBarRedraw  )

Definition at line 164 of file ScrollBarRedraw.c.

165{
166 if (!ColorsInit())
167 {
168 skip("Failed to initialize colors and solid color brushes\n");
169 return;
170 }
171
172 trace("Running test without specifying either CS_HREDRAW or CS_HREDRAW\n");
176 TEST_WINDOW_TITLE L" (No Redraw Flags)",
177 0);
178
179 trace("Running test with CS_HREDRAW\n");
183 TEST_WINDOW_TITLE L" (CS_HREDRAW)",
184 CS_HREDRAW);
185
186 trace("Running test with CS_VREDRAW\n");
190 TEST_WINDOW_TITLE L" (CS_VREDRAW)",
191 CS_VREDRAW);
192
193 trace("Running test with both CS_HREDRAW and CS_VREDRAW\n");
196 RunTestWindow(TEST_CLASS_NAME L"HRedrawVRedraw",
197 TEST_WINDOW_TITLE L" (CS_HREDRAW | CS_VREDRAW)",
199
200 trace("Test complete\n");
202}
#define TEST_CLASS_NAME
static BOOL ColorsInit(void)
static void RunTestWindow(PCWSTR ClassName, PCWSTR WindowTitle, UINT ClassStyle)
#define TEST_WINDOW_TITLE
#define L(x)
Definition: ntvdm.h:50
#define CS_VREDRAW
Definition: winuser.h:658
#define CS_HREDRAW
Definition: winuser.h:653

◆ WindowProc()

static LRESULT CALLBACK WindowProc ( HWND  Window,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 608 of file ScrollBarRedraw.c.

609{
610 switch (Message)
611 {
612 case WM_CREATE:
613 {
614 RECT Rect;
616
617 /* It's important for the test that the entire Window is visible. */
619 {
620 skip("Failed to set window as top-most, code: %ld\n", GetLastError());
621 return -1;
622 }
623
624 if (!GetClientRect(Window, &Rect))
625 {
626 skip("Failed to retrieve client area dimensions, code: %ld\n", GetLastError());
627 return -1;
628 }
629 ClientWidth = Rect.right;
630 ClientHeight = Rect.bottom;
631
632 if (!GetWindowRect(Window, &Rect))
633 {
634 skip("Failed to retrieve window dimensions, code: %ld\n", GetLastError());
635 return -1;
636 }
637 OrigWidth = Rect.right - Rect.left;
638 OrigHeight = Rect.bottom - Rect.top;
639
640 SmallWidth = max((OrigWidth * 3) / 4, 1);
641 SmallHeight = max((OrigHeight * 3) / 4, 1);
644
645 trace("OrigWidth: %d, OrigHeight: %d, SmallWidth: %d, SmallHeight: %d\n",
647
650
652 FsmTimer = 0;
654 return 0;
655 }
656
657 case WM_PAINT:
658 if (FsmTimer == 0 && WindowCreatedOk)
659 {
661 if (FsmTimer == 0)
662 {
663 skip("Failed to initialize FSM timer, code: %ld\n", GetLastError());
666 return 0;
667 }
668 }
669 return OnPaint(Window);
670
671 case WM_SIZE:
672 {
673 int NewWidth = LOWORD(lParam);
674 int NewHeight = HIWORD(lParam);
675
676 if (NewWidth != 0 && NewHeight != 0 &&
677 (NewWidth != ClientWidth || NewHeight != ClientHeight))
678 {
683
684 trace("New window size: %d x %d, new color: 0x%.8lX\n",
685 NewWidth, NewHeight, Colors[CurrentColor]);
686
687 ClientWidth = NewWidth;
688 ClientHeight = NewHeight;
689 }
690 return 0;
691 }
692
693 case WM_ERASEBKGND:
694 /* We use WM_PAINT instead, since WM_ERASEBKGND is issued before WM_SIZE. */
695 return 1;
696
697 case WM_TIMER:
698 if (wParam != 0 && wParam == FsmTimer)
699 {
700 return FsmStep(Window);
701 }
702 break;
703
704 case WM_NCDESTROY:
705 if (FsmTimer != 0)
706 {
708 FsmTimer = 0;
709
710 if (FsmState != FSM_STATE_END)
711 {
712 skip("Window closed before test concluded, FsmState: %d, FSM_STATE_END: %d.\n",
714 }
715 }
716 else if (WindowCreatedOk)
717 {
718 skip("Window closed before test began.\n");
719 }
720 return 0;
721
722 case WM_DESTROY:
724 return 0;
725 }
727}
static int FsmStep(HWND Window)
static UINT_PTR FsmTimer
#define FSM_STEP_PERIOD_MS
static BOOL WindowCreatedOk
static int OnPaint(HWND Window)
#define TEST_COLOR_COUNT
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define max(a, b)
Definition: svc.c:63
#define HIWORD(l)
Definition: typedefs.h:247
#define WM_PAINT
Definition: winuser.h:1623
#define WM_ERASEBKGND
Definition: winuser.h:1628
#define SetClassLongPtrW
Definition: winuser.h:5277
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WM_CREATE
Definition: winuser.h:1611
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_SIZE
Definition: winuser.h:1614
#define SWP_NOSIZE
Definition: winuser.h:1248
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define WM_TIMER
Definition: winuser.h:1745
#define WM_NCDESTROY
Definition: winuser.h:1687
#define WM_DESTROY
Definition: winuser.h:1612
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define GCLP_HBRBACKGROUND
Definition: winuser.h:672

Referenced by RunTestWindow().

Variable Documentation

◆ ClientHeight

int ClientHeight = 0
static

Definition at line 68 of file ScrollBarRedraw.c.

Referenced by FsmStep(), HideVertScrollBar(), ShowVertScrollBar(), and WindowProc().

◆ ClientWidth

int ClientWidth = 0
static

Definition at line 67 of file ScrollBarRedraw.c.

Referenced by FsmStep(), HideHorzScrollBar(), ShowHorzScrollBar(), and WindowProc().

◆ ColorBrushes

HBRUSH ColorBrushes[TEST_COLOR_COUNT] = { 0 }
static

Definition at line 37 of file ScrollBarRedraw.c.

Referenced by ColorsCleanup(), ColorsInit(), OnPaint(), RunTestWindow(), and WindowProc().

◆ Colors

COLORREF Colors[]
static
Initial value:
=
{
RGB(0x00, 0x00, 0x00),
RGB(0x00, 0x00, 0x80),
RGB(0x00, 0x80, 0x00),
RGB(0x00, 0x80, 0x80),
RGB(0x80, 0x00, 0x00),
RGB(0x80, 0x00, 0x80),
RGB(0x80, 0x80, 0x00),
RGB(0xC0, 0xC0, 0xC0),
RGB(0x80, 0x80, 0x80),
RGB(0x00, 0x00, 0xFF),
RGB(0x00, 0xFF, 0x00),
RGB(0x00, 0xFF, 0xFF),
RGB(0xFF, 0x00, 0x00),
RGB(0xFF, 0x00, 0xFF),
RGB(0xFF, 0xFF, 0x00),
}
#define RGB(r, g, b)
Definition: precomp.h:71

Definition at line 18 of file ScrollBarRedraw.c.

◆ CurrentColor

UINT CurrentColor = 0
static

Definition at line 64 of file ScrollBarRedraw.c.

Referenced by MultiWndProc(), OnPaint(), RunTestWindow(), and WindowProc().

◆ FsmState

FSM_STATE FsmState = FSM_STATE_START
static

Definition at line 65 of file ScrollBarRedraw.c.

Referenced by FsmStep(), and WindowProc().

◆ FsmTimer

UINT_PTR FsmTimer = 0
static

Definition at line 63 of file ScrollBarRedraw.c.

Referenced by WindowProc().

◆ HaveHRedraw

BOOL HaveHRedraw = FALSE
static

Definition at line 39 of file ScrollBarRedraw.c.

Referenced by FsmStep(), and START_TEST().

◆ HaveVRedraw

BOOL HaveVRedraw = FALSE
static

Definition at line 40 of file ScrollBarRedraw.c.

Referenced by FsmStep(), and START_TEST().

◆ OrigHeight

int OrigHeight = 0
static

Definition at line 71 of file ScrollBarRedraw.c.

Referenced by FsmStep(), and WindowProc().

◆ OrigWidth

int OrigWidth = 0
static

Definition at line 70 of file ScrollBarRedraw.c.

Referenced by FsmStep(), and WindowProc().

◆ SmallHeight

int SmallHeight = 0
static

Definition at line 73 of file ScrollBarRedraw.c.

Referenced by FsmStep(), and WindowProc().

◆ SmallWidth

int SmallWidth = 0
static

Definition at line 72 of file ScrollBarRedraw.c.

Referenced by FsmStep(), and WindowProc().

◆ WindowCreatedOk

BOOL WindowCreatedOk = FALSE
static

Definition at line 41 of file ScrollBarRedraw.c.

Referenced by WindowProc().