ReactOS 0.4.15-dev-7953-g1f49173
static.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <windows.h>
#include "commctrl.h"
#include "wine/test.h"
#include "v6util.h"
Include dependency graph for static.c:

Go to the source code of this file.

Macros

#define STRICT
 
#define WIN32_LEAN_AND_MEAN
 
#define TODO_COUNT   1
 
#define CTRL_ID   1995
 

Functions

static void flush_events (void)
 
static HWND create_static (DWORD style)
 
static LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void test_updates (int style, int flags)
 
static void test_set_text (void)
 
 START_TEST (static)
 

Variables

static HWND hMainWnd
 
static int g_nReceivedColorStatic
 

Macro Definition Documentation

◆ CTRL_ID

#define CTRL_ID   1995

Definition at line 36 of file static.c.

◆ STRICT

#define STRICT

Definition at line 24 of file static.c.

◆ TODO_COUNT

#define TODO_COUNT   1

Definition at line 34 of file static.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 26 of file static.c.

Function Documentation

◆ create_static()

static HWND create_static ( DWORD  style)
static

Definition at line 57 of file static.c.

58{
59 return CreateWindowA(WC_STATICA, "Test", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)CTRL_ID, NULL, 0);
60}
Arabic default style
Definition: afstyles.h:94
#define NULL
Definition: types.h:112
static HWND hMainWnd
Definition: static.c:38
#define CTRL_ID
Definition: static.c:36
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define WC_STATICA
Definition: commctrl.h:4679
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315

Referenced by test_set_text(), and test_updates().

◆ flush_events()

static void flush_events ( void  )
static

Definition at line 42 of file static.c.

43{
44 MSG msg;
45 int diff = 200;
46 int min_timeout = 100;
47 DWORD time = GetTickCount() + diff;
48
49 while (diff > 0)
50 {
51 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
52 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
53 diff = time - GetTickCount();
54 }
55}
#define msg(x)
Definition: auth_time.c:54
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define FALSE
Definition: types.h:117
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned long DWORD
Definition: ntddk_ex.h:95
__u16 time
Definition: mkdosfs.c:8
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define QS_ALLINPUT
Definition: winuser.h:903
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define PM_REMOVE
Definition: winuser.h:1196
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)

Referenced by test_updates().

◆ START_TEST()

START_TEST ( static  )

Definition at line 138 of file static.c.

139{
140 static const char classname[] = "testclass";
141 WNDCLASSEXA wndclass;
142 ULONG_PTR ctx_cookie;
143 HANDLE hCtx;
144
145 if (!load_v6_module(&ctx_cookie, &hCtx))
146 return;
147
148 wndclass.cbSize = sizeof(wndclass);
149 wndclass.style = CS_HREDRAW | CS_VREDRAW;
150 wndclass.lpfnWndProc = WndProc;
151 wndclass.cbClsExtra = 0;
152 wndclass.cbWndExtra = 0;
153 wndclass.hInstance = GetModuleHandleA(NULL);
158 wndclass.lpszClassName = classname;
159 wndclass.lpszMenuName = NULL;
160 RegisterClassExA(&wndclass);
161
162 hMainWnd = CreateWindowA(classname, "Test", WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, NULL, NULL,
165
166 test_updates(0, 0);
176
178
179 unload_v6_module(ctx_cookie, hCtx);
180}
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define TODO_COUNT
Definition: static.c:34
static void test_set_text(void)
Definition: static.c:123
static void test_updates(int style, int flags)
Definition: static.c:81
static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: static.c:62
#define SS_WHITERECT
Definition: pedump.c:698
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define SS_BLACKRECT
Definition: pedump.c:696
#define SS_SIMPLE
Definition: pedump.c:702
#define SS_BITMAP
Definition: pedump.c:704
#define SS_ICON
Definition: pedump.c:695
WCHAR classname[128]
Definition: startup.c:15
int cbClsExtra
Definition: winuser.h:3204
HINSTANCE hInstance
Definition: winuser.h:3206
HCURSOR hCursor
Definition: winuser.h:3208
LPCSTR lpszMenuName
Definition: winuser.h:3210
HICON hIconSm
Definition: winuser.h:3212
UINT style
Definition: winuser.h:3202
int cbWndExtra
Definition: winuser.h:3205
UINT cbSize
Definition: winuser.h:3201
WNDPROC lpfnWndProc
Definition: winuser.h:3203
LPCSTR lpszClassName
Definition: winuser.h:3211
HICON hIcon
Definition: winuser.h:3207
HBRUSH hbrBackground
Definition: winuser.h:3209
uint32_t ULONG_PTR
Definition: typedefs.h:65
static BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx)
Definition: v6util.h:71
static void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx)
Definition: v6util.h:63
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define WHITE_BRUSH
Definition: wingdi.h:902
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define SS_ETCHEDHORZ
Definition: winuser.h:343
#define SS_CENTERIMAGE
Definition: winuser.h:339
#define SS_ETCHEDVERT
Definition: winuser.h:344
#define IDI_APPLICATION
Definition: winuser.h:704
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2060
#define SW_SHOW
Definition: winuser.h:775
BOOL WINAPI DestroyWindow(_In_ HWND)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2090
const char * LPCSTR
Definition: xmlstorage.h:183

◆ test_set_text()

static void test_set_text ( void  )
static

Definition at line 123 of file static.c.

124{
125 HWND hStatic = create_static(SS_SIMPLE);
126 char buffA[10];
127
128 GetWindowTextA(hStatic, buffA, sizeof(buffA));
129 ok(!strcmp(buffA, "Test"), "got wrong text %s\n", buffA);
130
131 SetWindowTextA(hStatic, NULL);
132 GetWindowTextA(hStatic, buffA, sizeof(buffA));
133 ok(buffA[0] == 0, "got wrong text %s\n", buffA);
134
135 DestroyWindow(hStatic);
136}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok(value,...)
Definition: atltest.h:57
static HWND create_static(DWORD style)
Definition: static.c:57
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1330
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)

Referenced by START_TEST().

◆ test_updates()

static void test_updates ( int  style,
int  flags 
)
static

Definition at line 81 of file static.c.

82{
83 HWND hStatic = create_static(style);
84 RECT r1 = {20, 20, 30, 30};
85 int exp;
86
89 /* during each update parent WndProc will test the WM_CTLCOLORSTATIC message */
94 InvalidateRect(hStatic, &r1, FALSE);
95 UpdateWindow(hStatic);
96 InvalidateRect(hStatic, NULL, FALSE);
97 UpdateWindow(hStatic);
98
99 if ((style & SS_TYPEMASK) == SS_BITMAP)
100 {
101 HDC hdc = GetDC(hStatic);
102 COLORREF colour = GetPixel(hdc, 10, 10);
104 ok(colour == 0, "Unexpected pixel color.\n");
105 ReleaseDC(hStatic, hdc);
106 }
107
109 exp = 4;
110 else
111 exp = 1; /* SS_ETCHED* seems to send WM_CTLCOLORSTATIC only sometimes */
112
113 if (flags & TODO_COUNT)
115 ok(g_nReceivedColorStatic == exp, "Unexpected WM_CTLCOLORSTATIC value %d\n", g_nReceivedColorStatic);
116 else if ((style & SS_TYPEMASK) == SS_ICON || (style & SS_TYPEMASK) == SS_BITMAP)
117 ok(g_nReceivedColorStatic == exp, "Unexpected %u got %u\n", exp, g_nReceivedColorStatic);
118 else
119 ok(g_nReceivedColorStatic == exp, "Unexpected WM_CTLCOLORSTATIC value %d\n", g_nReceivedColorStatic);
120 DestroyWindow(hStatic);
121}
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
GLbitfield flags
Definition: glext.h:7161
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static int g_nReceivedColorStatic
Definition: static.c:39
static void flush_events(void)
Definition: static.c:42
static DNS_RECORDW r1
Definition: record.c:37
#define todo_wine
Definition: custom.c:79
DWORD exp
Definition: msg.c:16058
DWORD COLORREF
Definition: windef.h:300
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define SS_TYPEMASK
Definition: winuser.h:362
BOOL WINAPI UpdateWindow(_In_ HWND)
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by START_TEST().

◆ WndProc()

static LRESULT CALLBACK WndProc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 62 of file static.c.

63{
64 switch (msg)
65 {
67 {
68 HDC hdc = (HDC)wparam;
69 HRGN hrgn = CreateRectRgn(0, 0, 1, 1);
70 ok(GetClipRgn(hdc, hrgn) == 1, "Static controls during a WM_CTLCOLORSTATIC must have a clipping region\n");
74 }
75 break;
76 }
77
79}
static HRGN hrgn
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
pKey DeleteObject()
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LRESULT
Definition: windef.h:209
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
#define BLACK_BRUSH
Definition: wingdi.h:896
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1772
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by START_TEST().

Variable Documentation

◆ g_nReceivedColorStatic

int g_nReceivedColorStatic
static

Definition at line 39 of file static.c.

Referenced by test_updates(), and WndProc().

◆ hMainWnd

HWND hMainWnd
static

Definition at line 38 of file static.c.

Referenced by build_static(), create_static(), START_TEST(), and test_updates().