ReactOS  0.4.15-dev-5618-g8866b9d
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)
 
 START_TEST (brush)
 

Typedef Documentation

◆ STOCK_BRUSH

Function Documentation

◆ START_TEST()

START_TEST ( brush  )

Definition at line 364 of file brush.c.

365 {
366  test_solidbrush();
370  test_brush_org();
371 }
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:347
static void test_pattern_brush(void)
Definition: brush.c:119
static void test_palette_brush(void)
Definition: brush.c:274

◆ test_brush_org()

static void test_brush_org ( void  )
static

Definition at line 347 of file brush.c.

348 {
349  HDC hdc = GetDC( 0 );
350  POINT old, pt;
351 
352  SetBrushOrgEx( hdc, 0, 0, &old );
353 
354  SetBrushOrgEx( hdc, 1, 1, &pt );
355  ok( pt.x == 0 && pt.y == 0, "got %d,%d\n", pt.x, pt.y );
356  SetBrushOrgEx( hdc, 0x10000, -1, &pt );
357  ok( pt.x == 1 && pt.y == 1, "got %d,%d\n", pt.x, pt.y );
358  SetBrushOrgEx( hdc, old.x, old.y, &pt );
359  ok( pt.x == 0x10000 && pt.y == -1, "got %d,%d\n", pt.x, pt.y );
360 
361  ReleaseDC( 0, hdc );
362 }
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
HDC WINAPI GetDC(_In_opt_ HWND)
#define pt(x, y)
Definition: drawing.c:79
static HDC
Definition: imagelist.c:92
BOOL WINAPI SetBrushOrgEx(HDC hdc, int nXOrg, int nYOrg, LPPOINT lppt)
Definition: brush.c:284
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: main.c:9
#define ok(value,...)
Definition: atltest.h:57

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 %u\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 %08x\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 %lu/%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 %lu\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 %u\n", GetLastError() );
115  }
116  }
117 }
#define RGB(r, g, b)
Definition: precomp.h:62
UINT lbStyle
Definition: wingdi.h:1747
ULONG_PTR lbHatch
Definition: wingdi.h:1749
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define HS_API_MAX
Definition: wingdi.h:582
GLsizeiptr size
Definition: glext.h:5919
COLORREF lbColor
Definition: wingdi.h:1748
#define SetLastError(x)
Definition: compat.h:752
HBRUSH WINAPI CreateHatchBrush(INT fnStyle, COLORREF clrref)
Definition: brush.c:175
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
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
#define ok(value,...)
Definition: atltest.h:57
#define HS_DIAGCROSS
Definition: wingdi.h:578
#define BS_HATCHED
Definition: wingdi.h:1089
#define BS_SOLID
Definition: wingdi.h:1086

Referenced by START_TEST().

◆ test_palette_brush()

static void test_palette_brush ( void  )
static

Definition at line 274 of file brush.c.

275 {
276  char buffer[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD) + 16 * 16];
278  WORD *indices = (WORD *)info->bmiColors;
279  char pal_buffer[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
280  LOGPALETTE *pal = (LOGPALETTE *)pal_buffer;
281  HDC hdc = CreateCompatibleDC( 0 );
282  DWORD *dib_bits;
283  HBITMAP dib;
284  HBRUSH brush;
285  int i;
286  HPALETTE palette, palette2;
287 
288  memset( info, 0, sizeof(*info) );
289  info->bmiHeader.biSize = sizeof(info->bmiHeader);
290  info->bmiHeader.biWidth = 16;
291  info->bmiHeader.biHeight = 16;
292  info->bmiHeader.biPlanes = 1;
293  info->bmiHeader.biBitCount = 32;
294  info->bmiHeader.biCompression = BI_RGB;
295  dib = CreateDIBSection( NULL, info, DIB_RGB_COLORS, (void**)&dib_bits, NULL, 0 );
296  ok( dib != NULL, "CreateDIBSection failed\n" );
297 
298  info->bmiHeader.biBitCount = 8;
299  for (i = 0; i < 256; i++) indices[i] = 255 - i;
300  for (i = 0; i < 256; i++) ((BYTE *)(indices + 256))[i] = i;
302  ok( brush != NULL, "CreateDIBPatternBrushPt failed\n" );
303 
304  pal->palVersion = 0x300;
305  pal->palNumEntries = 256;
306  for (i = 0; i < 256; i++)
307  {
308  pal->palPalEntry[i].peRed = i * 2;
309  pal->palPalEntry[i].peGreen = i * 2;
310  pal->palPalEntry[i].peBlue = i * 2;
311  pal->palPalEntry[i].peFlags = 0;
312  }
313  palette = CreatePalette( pal );
314 
315  ok( SelectObject( hdc, dib ) != NULL, "SelectObject failed\n" );
316  ok( SelectPalette( hdc, palette, 0 ) != NULL, "SelectPalette failed\n" );
317  ok( SelectObject( hdc, brush ) != NULL, "SelectObject failed\n" );
318  memset( dib_bits, 0xaa, 16 * 16 * 4 );
319  PatBlt( hdc, 0, 0, 16, 16, PATCOPY );
320  for (i = 0; i < 256; i++)
321  {
322  DWORD expect = (pal->palPalEntry[255 - i].peRed << 16 |
323  pal->palPalEntry[255 - i].peGreen << 8 |
324  pal->palPalEntry[255 - i].peBlue);
325  ok( dib_bits[i] == expect, "wrong bits %x/%x at %u,%u\n", dib_bits[i], expect, i % 16, i / 16 );
326  }
327 
328  for (i = 0; i < 256; i++) pal->palPalEntry[i].peRed = i * 3;
329  palette2 = CreatePalette( pal );
330  ok( SelectPalette( hdc, palette2, 0 ) != NULL, "SelectPalette failed\n" );
331  memset( dib_bits, 0xaa, 16 * 16 * 4 );
332  PatBlt( hdc, 0, 0, 16, 16, PATCOPY );
333  for (i = 0; i < 256; i++)
334  {
335  DWORD expect = (pal->palPalEntry[255 - i].peRed << 16 |
336  pal->palPalEntry[255 - i].peGreen << 8 |
337  pal->palPalEntry[255 - i].peBlue);
338  ok( dib_bits[i] == expect, "wrong bits %x/%x at %u,%u\n", dib_bits[i], expect, i % 16, i / 16 );
339  }
340  DeleteDC( hdc );
341  DeleteObject( dib );
342  DeleteObject( brush );
344  DeleteObject( palette2 );
345 }
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
#define expect(expected, got)
Definition: brush.c:27
#define DIB_PAL_COLORS
Definition: wingdi.h:366
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLuint buffer
Definition: glext.h:5915
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
WORD palVersion
Definition: wingdi.h:1833
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
HBRUSH WINAPI CreateDIBPatternBrushPt(CONST VOID *lpPackedDIB, UINT fuColorSpec)
Definition: brush.c:146
ULONG RGBQUAD
Definition: precomp.h:50
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
HDC hdc
Definition: main.c:9
unsigned char BYTE
Definition: xxhash.c:193
static HPALETTE palette
Definition: clipboard.c:1345
#define PATCOPY
Definition: wingdi.h:335
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
BOOL WINAPI DeleteDC(_In_ HDC)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:199
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static const BYTE dib[]
Definition: ole2.c:201
struct tagPALETTEENTRY PALETTEENTRY
WORD palNumEntries
Definition: wingdi.h:1834
static HBITMAP
Definition: button.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:367
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:47

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  HBRUSH brush;
124  HBITMAP bitmap;
125  LOGBRUSH br;
126  INT ret;
127  void *bits;
128  DIBSECTION dib;
129  HGLOBAL mem;
130 
131  bitmap = CreateBitmap( 20, 20, 1, 1, NULL );
132  ok( bitmap != NULL, "CreateBitmap failed\n" );
133  brush = CreatePatternBrush( bitmap );
134  ok( brush != NULL, "CreatePatternBrush failed\n" );
135  memset( &br, 0x55, sizeof(br) );
136  ret = GetObjectW( brush, sizeof(br), &br );
137  ok( ret == sizeof(br), "wrong size %u\n", ret );
138  ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle );
139  ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
140  ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap );
141  DeleteObject( brush );
142 
143  br.lbStyle = BS_PATTERN8X8;
144  br.lbColor = 0x12345;
145  br.lbHatch = (ULONG_PTR)bitmap;
146  brush = CreateBrushIndirect( &br );
147  ok( brush != NULL, "CreatePatternBrush failed\n" );
148  memset( &br, 0x55, sizeof(br) );
149  ret = GetObjectW( brush, sizeof(br), &br );
150  ok( ret == sizeof(br), "wrong size %u\n", ret );
151  ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle );
152  ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
153  ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap );
154  ret = GetObjectW( bitmap, sizeof(dib), &dib );
155  ok( ret == sizeof(dib.dsBm), "wrong size %u\n", ret );
156  DeleteObject( bitmap );
157  ret = GetObjectW( bitmap, sizeof(dib), &dib );
158  ok( ret == 0, "wrong size %u\n", ret );
159  DeleteObject( brush );
160 
161  memset( info, 0, sizeof(buffer) );
162  info->bmiHeader.biSize = sizeof(info->bmiHeader);
163  info->bmiHeader.biHeight = 32;
164  info->bmiHeader.biWidth = 32;
165  info->bmiHeader.biBitCount = 1;
166  info->bmiHeader.biPlanes = 1;
167  info->bmiHeader.biCompression = BI_RGB;
168  bitmap = CreateDIBSection( 0, info, DIB_RGB_COLORS, (void**)&bits, NULL, 0 );
169  ok( bitmap != NULL, "CreateDIBSection failed\n" );
170 
171  /* MSDN says a DIB section is not allowed, but it works fine */
172  brush = CreatePatternBrush( bitmap );
173  ok( brush != NULL, "CreatePatternBrush failed\n" );
174  memset( &br, 0x55, sizeof(br) );
175  ret = GetObjectW( brush, sizeof(br), &br );
176  ok( ret == sizeof(br), "wrong size %u\n", ret );
177  ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle );
178  ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
179  ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap );
180  ret = GetObjectW( bitmap, sizeof(dib), &dib );
181  ok( ret == sizeof(dib), "wrong size %u\n", ret );
182  DeleteObject( brush );
183  DeleteObject( bitmap );
184 
186  ok( brush != NULL, "CreatePatternBrush failed\n" );
187  memset( &br, 0x55, sizeof(br) );
188  ret = GetObjectW( brush, sizeof(br), &br );
189  ok( ret == sizeof(br), "wrong size %u\n", ret );
190  ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle );
191  ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
192  ok( (BITMAPINFO *)br.lbHatch == info || broken(!br.lbHatch), /* nt4 */
193  "wrong handle %p/%p\n", (BITMAPINFO *)br.lbHatch, info );
194  DeleteObject( brush );
195 
197  br.lbColor = DIB_PAL_COLORS;
198  br.lbHatch = (ULONG_PTR)info;
199  brush = CreateBrushIndirect( &br );
200  ok( brush != NULL, "CreatePatternBrush failed\n" );
201  memset( &br, 0x55, sizeof(br) );
202  ret = GetObjectW( brush, sizeof(br), &br );
203  ok( ret == sizeof(br), "wrong size %u\n", ret );
204  ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle );
205  ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
206  ok( (BITMAPINFO *)br.lbHatch == info || broken(!br.lbHatch), /* nt4 */
207  "wrong handle %p/%p\n", (BITMAPINFO *)br.lbHatch, info );
208 
209  mem = GlobalAlloc( GMEM_MOVEABLE, sizeof(buffer) );
210  memcpy( GlobalLock( mem ), buffer, sizeof(buffer) );
211 
212  br.lbStyle = BS_DIBPATTERN;
213  br.lbColor = DIB_PAL_COLORS;
214  br.lbHatch = (ULONG_PTR)mem;
215  brush = CreateBrushIndirect( &br );
216  ok( brush != NULL, "CreatePatternBrush failed\n" );
217  memset( &br, 0x55, sizeof(br) );
218  ret = GetObjectW( brush, sizeof(br), &br );
219  ok( ret == sizeof(br), "wrong size %u\n", ret );
220  ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle );
221  ok( br.lbColor == 0, "wrong color %u\n", br.lbColor );
222  ok( (HGLOBAL)br.lbHatch != mem, "wrong handle %p/%p\n", (HGLOBAL)br.lbHatch, mem );
223  bits = GlobalLock( mem );
224  ok( (HGLOBAL)br.lbHatch == bits || broken(!br.lbHatch), /* nt4 */
225  "wrong handle %p/%p\n", (HGLOBAL)br.lbHatch, bits );
226  ret = GlobalFlags( mem );
227  ok( ret == 2, "wrong flags %x\n", ret );
228  DeleteObject( brush );
229  ret = GlobalFlags( mem );
230  ok( ret == 2, "wrong flags %x\n", ret );
231 
233  ok( brush != 0, "CreateDIBPatternBrushPt failed\n" );
234  DeleteObject( brush );
236  ok( brush != 0, "CreateDIBPatternBrushPt failed\n" );
237  DeleteObject( brush );
239  ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );
241  ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );
242 
243  info->bmiHeader.biBitCount = 8;
244  info->bmiHeader.biCompression = BI_RLE8;
246  ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );
247 
248  info->bmiHeader.biBitCount = 4;
249  info->bmiHeader.biCompression = BI_RLE4;
251  ok( !brush, "CreateDIBPatternBrushPt succeeded\n" );
252 
254  br.lbColor = DIB_RGB_COLORS;
255  br.lbHatch = (ULONG_PTR)mem;
256  brush = CreateBrushIndirect( &br );
257  ok( !brush, "CreatePatternBrush succeeded\n" );
258 
259  br.lbStyle = BS_MONOPATTERN;
260  br.lbColor = DIB_RGB_COLORS;
261  br.lbHatch = (ULONG_PTR)mem;
262  brush = CreateBrushIndirect( &br );
263  ok( !brush, "CreatePatternBrush succeeded\n" );
264 
265  br.lbStyle = BS_INDEXED;
266  br.lbColor = DIB_RGB_COLORS;
267  br.lbHatch = (ULONG_PTR)mem;
268  brush = CreateBrushIndirect( &br );
269  ok( !brush, "CreatePatternBrush succeeded\n" );
270 
271  GlobalFree( mem );
272 }
HBRUSH WINAPI CreateBrushIndirect(CONST LOGBRUSH *LogBrush)
Definition: brush.c:206
#define BS_DIBPATTERN
Definition: wingdi.h:1092
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define DIB_PAL_COLORS
Definition: wingdi.h:366
UINT lbStyle
Definition: wingdi.h:1747
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
UINT NTAPI GlobalFlags(HGLOBAL hMem)
Definition: heapmem.c:520
ULONG_PTR lbHatch
Definition: wingdi.h:1749
HBRUSH WINAPI CreatePatternBrush(HBITMAP hbmp)
Definition: brush.c:186
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLuint buffer
Definition: glext.h:5915
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
int32_t INT
Definition: typedefs.h:58
#define BS_DIBPATTERN8X8
Definition: wingdi.h:1095
HBRUSH WINAPI CreateDIBPatternBrushPt(CONST VOID *lpPackedDIB, UINT fuColorSpec)
Definition: brush.c:146
Definition: uimain.c:88
ULONG RGBQUAD
Definition: precomp.h:50
COLORREF lbColor
Definition: wingdi.h:1748
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
#define BS_MONOPATTERN
Definition: wingdi.h:1096
int ret
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define broken(x)
Definition: _sntprintf.h:21
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:199
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static const BYTE dib[]
Definition: ole2.c:201
#define BI_RLE4
Definition: precomp.h:48
#define BS_PATTERN
Definition: wingdi.h:1090
#define BS_PATTERN8X8
Definition: wingdi.h:1094
Definition: mem.c:156
#define ULONG_PTR
Definition: config.h:101
static HBITMAP bitmap
Definition: clipboard.c:1344
static HBITMAP
Definition: button.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:367
#define BS_INDEXED
Definition: wingdi.h:1091
#define BI_RLE8
Definition: wingdi.h:35
#define memset(x, y, z)
Definition: compat.h:39
#define BS_DIBPATTERNPT
Definition: wingdi.h:1093
#define BI_RGB
Definition: precomp.h:47
#define GMEM_MOVEABLE
Definition: winbase.h:294
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

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<sizeof(stock)/sizeof(stock[0]); 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=%d\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%08x expected 0x%08x\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=%d\n", stock[i].name, GetLastError());
72  ok(br.lbColor==stock[i].color, "stock %s brush unexpected color, got 0x%08x expected 0x%08x\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 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define RGB(r, g, b)
Definition: precomp.h:62
UINT lbStyle
Definition: wingdi.h:1747
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define WHITE_BRUSH
Definition: wingdi.h:902
int32_t INT
Definition: typedefs.h:58
GLuint color
Definition: glext.h:6243
#define LTGRAY_BRUSH
Definition: wingdi.h:900
#define GRAY_BRUSH
Definition: wingdi.h:898
#define BLACK_BRUSH
Definition: wingdi.h:896
COLORREF lbColor
Definition: wingdi.h:1748
char * name
Definition: compiler.c:66
int ret
#define broken(x)
Definition: _sntprintf.h:21
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
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
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
Definition: name.c:38
#define BS_SOLID
Definition: wingdi.h:1086
#define memset(x, y, z)
Definition: compat.h:39
HBRUSH WINAPI CreateSolidBrush(IN COLORREF crColor)
Definition: brush.c:196

Referenced by START_TEST().