ReactOS 0.4.17-dev-116-ga4b6fe9
brush.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/test.h"
Include dependency graph for brush.c:

Go to the source code of this file.

Classes

struct  _STOCK_BRUSH
 

Typedefs

typedef struct _STOCK_BRUSH STOCK_BRUSH
 

Functions

static void test_solidbrush (void)
 
static void test_hatch_brush (void)
 
static void test_pattern_brush (void)
 
static void test_palette_brush (void)
 
static void test_brush_org (void)
 
static void test_null_brush (void)
 
 START_TEST (brush)
 

Typedef Documentation

◆ STOCK_BRUSH

Function Documentation

◆ START_TEST()

START_TEST ( brush  )

Definition at line 457 of file brush.c.

458{
465}
static void test_pattern_brush(void)
Definition: brush.c:119
static void test_hatch_brush(void)
Definition: brush.c:83
static void test_solidbrush(void)
Definition: brush.c:36
static void test_brush_org(void)
Definition: brush.c:410
static void test_palette_brush(void)
Definition: brush.c:337
static void test_null_brush(void)
Definition: brush.c:447

◆ test_brush_org()

static void test_brush_org ( void  )
static

Definition at line 410 of file brush.c.

411{
412 HDC hdc = GetDC( 0 );
413 POINT old, pt;
414 BOOL ret;
415
416 ret = SetBrushOrgEx( hdc, 0, 0, &old );
417 ok(ret, "Unexpected return value %d.\n", ret);
418
419 ret = SetBrushOrgEx( hdc, 1, 1, &pt );
420 ok(ret, "Unexpected return value %d.\n", ret);
421 ok( pt.x == 0 && pt.y == 0, "got %ld,%ld\n", pt.x, pt.y );
422 ret = SetBrushOrgEx( hdc, 0x10000, -1, &pt );
423 ok(ret, "Unexpected return value %d.\n", ret);
424 ok( pt.x == 1 && pt.y == 1, "got %ld,%ld\n", pt.x, pt.y );
425 ret = SetBrushOrgEx( hdc, old.x, old.y, &pt );
426 ok(ret, "Unexpected return value %d.\n", ret);
427 ok( pt.x == 0x10000 && pt.y == -1, "got %ld,%ld\n", pt.x, pt.y );
428
429 ret = GetBrushOrgEx( hdc, &pt );
430 ok(ret, "Unexpected return value %d.\n", ret);
431 ok( pt.x == 0 && pt.y == 0, "got %ld,%ld\n", pt.x, pt.y );
432 pt.x = 10;
433 pt.y = 20;
434 ret = FixBrushOrgEx( hdc, 2, 3, &pt );
436 ok(!ret, "Unexpected return value %d.\n", ret);
438 ok( pt.x == 10 && pt.y == 20, "got %ld,%ld\n", pt.x, pt.y );
439 ret = GetBrushOrgEx( hdc, &pt );
440 ok(ret, "Unexpected return value %d.\n", ret);
442 ok( pt.x == 0 && pt.y == 0, "got %ld,%ld\n", pt.x, pt.y );
443
444 ReleaseDC( 0, hdc );
445}
#define ok(value,...)
Definition: atltest.h:57
#define pt(x, y)
Definition: drawing.c:79
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
#define todo_wine
Definition: minitest.h:80
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
BOOL WINAPI GetBrushOrgEx(_In_ HDC, _Out_ LPPOINT)
BOOL WINAPI SetBrushOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
BOOL WINAPI FixBrushOrgEx(_In_ HDC, _In_ int, _In_ int, _In_opt_ LPPOINT)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by START_TEST().

◆ test_hatch_brush()

static void test_hatch_brush ( void  )
static

Definition at line 83 of file brush.c.

84{
85 int i, size;
86 HBRUSH brush;
87 LOGBRUSH lb;
88
89 for (i = 0; i < 20; i++)
90 {
91 SetLastError( 0xdeadbeef );
92 brush = CreateHatchBrush( i, RGB(12,34,56) );
93 if (i < HS_API_MAX)
94 {
95 ok( brush != 0, "%u: CreateHatchBrush failed err %lu\n", i, GetLastError() );
96 size = GetObjectW( brush, sizeof(lb), &lb );
97 ok( size == sizeof(lb), "wrong size %u\n", size );
98 ok( lb.lbColor == RGB(12,34,56), "wrong color %08lx\n", lb.lbColor );
99 if (i <= HS_DIAGCROSS)
100 {
101 ok( lb.lbStyle == BS_HATCHED, "wrong style %u\n", lb.lbStyle );
102 ok( lb.lbHatch == i, "wrong hatch %Iu/%u\n", lb.lbHatch, i );
103 }
104 else
105 {
106 ok( lb.lbStyle == BS_SOLID, "wrong style %u\n", lb.lbStyle );
107 ok( lb.lbHatch == 0, "wrong hatch %Iu\n", lb.lbHatch );
108 }
109 DeleteObject( brush );
110 }
111 else
112 {
113 ok( !brush, "%u: CreateHatchBrush succeeded\n", i );
114 ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
115 }
116 }
117}
#define SetLastError(x)
Definition: compat.h:752
#define RGB(r, g, b)
Definition: precomp.h:67
pKey DeleteObject()
GLsizeiptr size
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT lbStyle
Definition: wingdi.h:2193
ULONG_PTR lbHatch
Definition: wingdi.h:2195
COLORREF lbColor
Definition: wingdi.h:2194
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HS_API_MAX
Definition: wingdi.h:582
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define BS_HATCHED
Definition: wingdi.h:1089
#define HS_DIAGCROSS
Definition: wingdi.h:578
HBRUSH WINAPI CreateHatchBrush(_In_ int, _In_ COLORREF)
#define BS_SOLID
Definition: wingdi.h:1086

Referenced by START_TEST().

◆ test_null_brush()

static void test_null_brush ( void  )
static

Definition at line 447 of file brush.c.

448{
449 LOGBRUSH lb;
450 HBRUSH brush;
451
452 lb.lbStyle = BS_NULL;
453 brush = CreateBrushIndirect(&lb);
454 ok(brush == GetStockObject(NULL_BRUSH), "brush is not NULL_BRUSH\n");
455}
HBRUSH WINAPI CreateBrushIndirect(_In_ const LOGBRUSH *plb)
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define NULL_BRUSH
Definition: wingdi.h:901
#define BS_NULL
Definition: wingdi.h:1087

Referenced by START_TEST().

◆ test_palette_brush()

static void test_palette_brush ( void  )
static

Definition at line 337 of file brush.c.

338{
339 char buffer[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD) + 16 * 16];
341 WORD *indices = (WORD *)info->bmiColors;
342 char pal_buffer[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
343 LOGPALETTE *pal = (LOGPALETTE *)pal_buffer;
345 DWORD *dib_bits;
346 HBITMAP dib;
347 HBRUSH brush;
348 int i;
349 HPALETTE palette, palette2;
350
351 memset( info, 0, sizeof(*info) );
352 info->bmiHeader.biSize = sizeof(info->bmiHeader);
353 info->bmiHeader.biWidth = 16;
354 info->bmiHeader.biHeight = 16;
355 info->bmiHeader.biPlanes = 1;
356 info->bmiHeader.biBitCount = 32;
357 info->bmiHeader.biCompression = BI_RGB;
358 dib = CreateDIBSection( NULL, info, DIB_RGB_COLORS, (void**)&dib_bits, NULL, 0 );
359 ok( dib != NULL, "CreateDIBSection failed\n" );
360
361 info->bmiHeader.biBitCount = 8;
362 for (i = 0; i < 256; i++) indices[i] = 255 - i;
363 for (i = 0; i < 256; i++) ((BYTE *)(indices + 256))[i] = i;
365 ok( brush != NULL, "CreateDIBPatternBrushPt failed\n" );
366
367 pal->palVersion = 0x300;
368 pal->palNumEntries = 256;
369 for (i = 0; i < 256; i++)
370 {
371 pal->palPalEntry[i].peRed = i * 2;
372 pal->palPalEntry[i].peGreen = i * 2;
373 pal->palPalEntry[i].peBlue = i * 2;
374 pal->palPalEntry[i].peFlags = 0;
375 }
376 palette = CreatePalette( pal );
377
378 ok( SelectObject( hdc, dib ) != NULL, "SelectObject failed\n" );
379 ok( SelectPalette( hdc, palette, 0 ) != NULL, "SelectPalette failed\n" );
380 ok( SelectObject( hdc, brush ) != NULL, "SelectObject failed\n" );
381 memset( dib_bits, 0xaa, 16 * 16 * 4 );
382 PatBlt( hdc, 0, 0, 16, 16, PATCOPY );
383 for (i = 0; i < 256; i++)
384 {
385 DWORD expect = (pal->palPalEntry[255 - i].peRed << 16 |
386 pal->palPalEntry[255 - i].peGreen << 8 |
387 pal->palPalEntry[255 - i].peBlue);
388 ok( dib_bits[i] == expect, "wrong bits %lx/%lx at %u,%u\n", dib_bits[i], expect, i % 16, i / 16 );
389 }
390
391 for (i = 0; i < 256; i++) pal->palPalEntry[i].peRed = i * 3;
392 palette2 = CreatePalette( pal );
393 ok( SelectPalette( hdc, palette2, 0 ) != NULL, "SelectPalette failed\n" );
394 memset( dib_bits, 0xaa, 16 * 16 * 4 );
395 PatBlt( hdc, 0, 0, 16, 16, PATCOPY );
396 for (i = 0; i < 256; i++)
397 {
398 DWORD expect = (pal->palPalEntry[255 - i].peRed << 16 |
399 pal->palPalEntry[255 - i].peGreen << 8 |
400 pal->palPalEntry[255 - i].peBlue);
401 ok( dib_bits[i] == expect, "wrong bits %lx/%lx at %u,%u\n", dib_bits[i], expect, i % 16, i / 16 );
402 }
403 DeleteDC( hdc );
404 DeleteObject( dib );
405 DeleteObject( brush );
407 DeleteObject( palette2 );
408}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
#define NULL
Definition: types.h:112
ULONG RGBQUAD
Definition: precomp.h:47
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
static HBITMAP
Definition: button.c:44
static HPALETTE palette
Definition: clipboard.c:1457
#define memset(x, y, z)
Definition: compat.h:39
WORD palNumEntries
Definition: wingdi.h:2280
WORD palVersion
Definition: wingdi.h:2279
#define BI_RGB
Definition: uefivid.c:46
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define DIB_RGB_COLORS
Definition: wingdi.h:367
struct tagPALETTEENTRY PALETTEENTRY
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define DIB_PAL_COLORS
Definition: wingdi.h:366
#define PATCOPY
Definition: wingdi.h:335
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HBRUSH WINAPI CreateDIBPatternBrushPt(_In_ const VOID *pvPackedDIB, _In_ UINT uUsage)
BOOL WINAPI DeleteDC(_In_ HDC)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_pattern_brush()

static void test_pattern_brush ( void  )
static

Definition at line 119 of file brush.c.

120{
121 char buffer[sizeof(BITMAPINFOHEADER) + 2 * sizeof(RGBQUAD) + 32 * 32 / 8];
123 HBITMAP bitmap, bitmap2, old_bitmap;
124 HBRUSH brush, brush2;
125 HDC hdc, hdc_screen;
127 BOOL result;
128 LOGBRUSH br;
129 BITMAP bm;
130 RECT rect;
131 INT ret;
132 void *bits;
133 DIBSECTION dib;
134 HGLOBAL mem;
135
136 bitmap = CreateBitmap( 20, 20, 1, 1, NULL );
137 ok( bitmap != NULL, "CreateBitmap failed\n" );
138 brush = CreatePatternBrush( bitmap );
139 ok( brush != NULL, "CreatePatternBrush failed\n" );
140 memset( &br, 0x55, sizeof(br) );
141 ret = GetObjectW( brush, sizeof(br), &br );
142 ok( ret == sizeof(br), "wrong size %u\n", ret );
143 ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle );
144 ok( br.lbColor == 0, "wrong color %lu\n", br.lbColor );
145 ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap );
146 DeleteObject( brush );
147
149 br.lbColor = 0x12345;
151 brush = CreateBrushIndirect( &br );
152 ok( brush != NULL, "CreatePatternBrush failed\n" );
153 memset( &br, 0x55, sizeof(br) );
154 ret = GetObjectW( brush, sizeof(br), &br );
155 ok( ret == sizeof(br), "wrong size %u\n", ret );
156 ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle );
157 ok( br.lbColor == 0, "wrong color %lu\n", br.lbColor );
158 ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap );
159 ret = GetObjectW( bitmap, sizeof(dib), &dib );
160 ok( ret == sizeof(dib.dsBm), "wrong size %u\n", ret );
162 ret = GetObjectW( bitmap, sizeof(dib), &dib );
163 ok( ret == 0, "wrong size %u\n", ret );
164 DeleteObject( brush );
165
166 memset( info, 0, sizeof(buffer) );
167 info->bmiHeader.biSize = sizeof(info->bmiHeader);
168 info->bmiHeader.biHeight = 32;
169 info->bmiHeader.biWidth = 32;
170 info->bmiHeader.biBitCount = 1;
171 info->bmiHeader.biPlanes = 1;
172 info->bmiHeader.biCompression = BI_RGB;
174 ok( bitmap != NULL, "CreateDIBSection failed\n" );
175
176 /* MSDN says a DIB section is not allowed, but it works fine */
177 brush = CreatePatternBrush( bitmap );
178 ok( brush != NULL, "CreatePatternBrush failed\n" );
179 memset( &br, 0x55, sizeof(br) );
180 ret = GetObjectW( brush, sizeof(br), &br );
181 ok( ret == sizeof(br), "wrong size %u\n", ret );
182 ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle );
183 ok( br.lbColor == 0, "wrong color %lu\n", br.lbColor );
184 ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap );
185 ret = GetObjectW( bitmap, sizeof(dib), &dib );
186 ok( ret == sizeof(dib), "wrong size %u\n", ret );
187 DeleteObject( brush );
189
191 ok( brush != NULL, "CreatePatternBrush failed\n" );
192 memset( &br, 0x55, sizeof(br) );
193 ret = GetObjectW( brush, sizeof(br), &br );
194 ok( ret == sizeof(br), "wrong size %u\n", ret );
195 ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle );
196 ok( br.lbColor == 0, "wrong color %lu\n", br.lbColor );
197 ok( (BITMAPINFO *)br.lbHatch == info || broken(!br.lbHatch), /* nt4 */
198 "wrong handle %p/%p\n", (BITMAPINFO *)br.lbHatch, info );
199 DeleteObject( brush );
200
203 br.lbHatch = (ULONG_PTR)info;
204 brush = CreateBrushIndirect( &br );
205 ok( brush != NULL, "CreatePatternBrush failed\n" );
206 memset( &br, 0x55, sizeof(br) );
207 ret = GetObjectW( brush, sizeof(br), &br );
208 ok( ret == sizeof(br), "wrong size %u\n", ret );
209 ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle );
210 ok( br.lbColor == 0, "wrong color %lu\n", br.lbColor );
211 ok( (BITMAPINFO *)br.lbHatch == info || broken(!br.lbHatch), /* nt4 */
212 "wrong handle %p/%p\n", (BITMAPINFO *)br.lbHatch, info );
213
214 mem = GlobalAlloc( GMEM_MOVEABLE, sizeof(buffer) );
215 memcpy( GlobalLock( mem ), buffer, sizeof(buffer) );
216
219 br.lbHatch = (ULONG_PTR)mem;
220 brush = CreateBrushIndirect( &br );
221 ok( brush != NULL, "CreatePatternBrush failed\n" );
222 memset( &br, 0x55, sizeof(br) );
223 ret = GetObjectW( brush, sizeof(br), &br );
224 ok( ret == sizeof(br), "wrong size %u\n", ret );
225 ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle );
226 ok( br.lbColor == 0, "wrong color %lu\n", br.lbColor );
227 ok( (HGLOBAL)br.lbHatch != mem, "wrong handle %p/%p\n", (HGLOBAL)br.lbHatch, mem );
228 bits = GlobalLock( mem );
229 ok( (HGLOBAL)br.lbHatch == bits || broken(!br.lbHatch), /* nt4 */
230 "wrong handle %p/%p\n", (HGLOBAL)br.lbHatch, bits );
231 ret = GlobalFlags( mem );
232 ok( ret == 2, "wrong flags %x\n", ret );
233 DeleteObject( brush );
234 ret = GlobalFlags( mem );
235 ok( ret == 2, "wrong flags %x\n", ret );
236
238 ok( brush != 0, "CreateDIBPatternBrushPt failed\n" );
239 DeleteObject( brush );
241 ok( brush != 0, "CreateDIBPatternBrushPt failed\n" );
242 DeleteObject( brush );
244 ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );
246 ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );
247
248 info->bmiHeader.biBitCount = 8;
249 info->bmiHeader.biCompression = BI_RLE8;
251 ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );
252
253 info->bmiHeader.biBitCount = 4;
254 info->bmiHeader.biCompression = BI_RLE4;
256 ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );
257
260 br.lbHatch = (ULONG_PTR)mem;
261 brush = CreateBrushIndirect( &br );
262 ok( !brush, "CreatePatternBrush succeeded\n" );
263
266 br.lbHatch = (ULONG_PTR)mem;
267 brush = CreateBrushIndirect( &br );
268 ok( !brush, "CreatePatternBrush succeeded\n" );
269
270 br.lbStyle = BS_INDEXED;
272 br.lbHatch = (ULONG_PTR)mem;
273 brush = CreateBrushIndirect( &br );
274 ok( !brush, "CreatePatternBrush succeeded\n" );
275
276 GlobalFree( mem );
277
278 /* Test deleting bitmap after brush creation */
279 /* Create hdc and bitmaps */
280 hdc_screen = GetDC( NULL );
281 hdc = CreateCompatibleDC( hdc_screen );
282 bitmap = CreateCompatibleBitmap( hdc_screen, 16, 16 );
283 bitmap2 = CreateCompatibleBitmap( hdc_screen, 16, 16 );
284
285 /* Fill the first bitmap with 0xff5511 */
286 old_bitmap = SelectObject( hdc, bitmap );
287 SetRect( &rect, 0, 0, 16, 16 );
288 brush = CreateSolidBrush( 0xff5511 );
289 result = FillRect( hdc, &rect, brush );
290 ok( result, "FillRect failed, error %ld.\n", GetLastError() );
291 DeleteObject( brush );
292 color = GetPixel( hdc, 10, 10 );
293 ok( color == 0xff5511, "Expected color %#x, got %#lx.\n", 0xff5511, color );
294
295 /* Create a pattern brush with the first bitmap filled with 0xff5511 */
296 brush = CreatePatternBrush( bitmap );
297 ok( brush != NULL, "CreatePatternBrush failed, error %lu.\n", GetLastError() );
298
299 /* Delete the first bitmap used for pattern brush creation */
302
303 memset( &br, 0, sizeof(br) );
304 ret = GetObjectW( brush, sizeof(br), &br );
305 ok( ret == sizeof(br), "wrong size %u\n", ret );
306 ok( br.lbColor == 0, "wrong color %lu\n", br.lbColor );
307 ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle );
308 ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap );
309
310 /* The first bitmap is now invalid */
311 memset( &bm, 0, sizeof (bm));
312 ret = GetObjectW( bitmap, sizeof(bm), &bm );
313 ok( !ret, "wrong size %u\n", ret );
314
315 /* Fill hdc with 0xabcdef */
316 brush2 = CreateSolidBrush( 0xabcdef );
317 result = FillRect( hdc, &rect, brush2 );
318 ok( result, "FillRect failed, error %ld.\n", GetLastError() );
319 color = GetPixel( hdc, 10, 10 );
320 ok( color == 0xabcdef, "Expected color %#x, got %#lx.\n", 0xabcdef, color );
321 DeleteObject( brush2 );
322
323 /* Fill hdc with the brush created with the deleted bitmap */
324 /* FillRect() succeeds and hdc is filled with the deleted bitmap content */
325 result = FillRect( hdc, &rect, brush );
326 ok( result, "FillRect failed, error %ld.\n", GetLastError() );
327 color = GetPixel( hdc, 10, 10 );
328 ok( color == 0xff5511, "Expected color %#x, got %#lx.\n", 0xff5511, color );
329 DeleteObject( brush );
330
331 SelectObject( hdc, old_bitmap );
333 DeleteDC( hdc );
334 ReleaseDC( NULL, hdc_screen );
335}
#define broken(x)
Definition: atltest.h:178
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
RECT rect
Definition: combotst.c:67
#define BI_RLE4
Definition: precomp.h:45
#define ULONG_PTR
Definition: config.h:101
GLuint color
Definition: glext.h:6243
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLuint64EXT * result
Definition: glext.h:11304
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
UINT NTAPI GlobalFlags(HGLOBAL hMem)
Definition: heapmem.c:520
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define bits
Definition: infblock.c:15
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HBITMAP bitmap2
Definition: clipboard.c:1456
Definition: uimain.c:89
Definition: mem.c:349
BITMAP dsBm
Definition: wingdi.h:2115
int32_t INT
Definition: typedefs.h:58
#define GMEM_MOVEABLE
Definition: winbase.h:318
DWORD COLORREF
Definition: windef.h:100
#define BS_MONOPATTERN
Definition: wingdi.h:1096
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define BS_PATTERN8X8
Definition: wingdi.h:1094
#define BS_PATTERN
Definition: wingdi.h:1090
#define BS_DIBPATTERNPT
Definition: wingdi.h:1093
#define BS_DIBPATTERN8X8
Definition: wingdi.h:1095
#define BS_DIBPATTERN
Definition: wingdi.h:1092
#define BS_INDEXED
Definition: wingdi.h:1091
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define BI_RLE8
Definition: wingdi.h:35
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by START_TEST().

◆ test_solidbrush()

static void test_solidbrush ( void  )
static

Definition at line 36 of file brush.c.

37{
38 static const STOCK_BRUSH stock[] = {
39 {RGB(255,255,255), WHITE_BRUSH, "white"},
40 {RGB(192,192,192), LTGRAY_BRUSH, "ltgray"},
41 {RGB(128,128,128), GRAY_BRUSH, "gray"},
42 {RGB(0,0,0), BLACK_BRUSH, "black"},
43 {RGB(0,0,255), -1, "blue"}
44 };
45 HBRUSH solidBrush;
46 HBRUSH stockBrush;
47 LOGBRUSH br;
48 size_t i;
49 INT ret;
50
51 for(i = 0; i < ARRAY_SIZE(stock); i++) {
52 solidBrush = CreateSolidBrush(stock[i].color);
53
54 if(stock[i].stockobj != -1) {
55 stockBrush = GetStockObject(stock[i].stockobj);
56 ok(stockBrush!=solidBrush ||
57 broken(stockBrush==solidBrush), /* win9x does return stock object */
58 "Stock %s brush equals solid %s brush\n", stock[i].name, stock[i].name);
59 }
60 else
61 stockBrush = NULL;
62 memset(&br, 0, sizeof(br));
63 ret = GetObjectW(solidBrush, sizeof(br), &br);
64 ok( ret !=0, "GetObject on solid %s brush failed, error=%ld\n", stock[i].name, GetLastError());
65 ok(br.lbStyle==BS_SOLID, "%s brush has wrong style, got %d expected %d\n", stock[i].name, br.lbStyle, BS_SOLID);
66 ok(br.lbColor==stock[i].color, "%s brush has wrong color, got 0x%08lx expected 0x%08lx\n", stock[i].name, br.lbColor, stock[i].color);
67
68 if(stockBrush) {
69 /* Sanity check, make sure the colors being compared do in fact have a stock brush */
70 ret = GetObjectW(stockBrush, sizeof(br), &br);
71 ok( ret !=0, "GetObject on stock %s brush failed, error=%ld\n", stock[i].name, GetLastError());
72 ok(br.lbColor==stock[i].color, "stock %s brush unexpected color, got 0x%08lx expected 0x%08lx\n", stock[i].name, br.lbColor, stock[i].color);
73 }
74
75 DeleteObject(solidBrush);
76 ret = GetObjectW(solidBrush, sizeof(br), &br);
77 ok(ret==0 ||
78 broken(ret!=0), /* win9x */
79 "GetObject succeeded on a deleted %s brush\n", stock[i].name);
80 }
81}
#define ARRAY_SIZE(A)
Definition: main.h:20
char * name
Definition: compiler.c:66
Definition: name.c:39
#define LTGRAY_BRUSH
Definition: wingdi.h:900
#define WHITE_BRUSH
Definition: wingdi.h:902
#define GRAY_BRUSH
Definition: wingdi.h:898
#define BLACK_BRUSH
Definition: wingdi.h:896

Referenced by START_TEST().