2 * Unit test suite for cursors and icons.
4 * Copyright 2006 Michael Kaufmann
5 * Copyright 2007 Dmitry Timoshkov
6 * Copyright 2007-2008 Andrew Riedi
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
46 } CURSORICONFILEDIRENTRY
;
53 CURSORICONFILEDIRENTRY idEntries
[1];
56 #define RIFF_FOURCC( c0, c1, c2, c3 ) \
57 ( (DWORD)(BYTE)(c0) | ( (DWORD)(BYTE)(c1) << 8 ) | \
58 ( (DWORD)(BYTE)(c2) << 16 ) | ( (DWORD)(BYTE)(c3) << 24 ) )
60 #define ANI_RIFF_ID RIFF_FOURCC('R', 'I', 'F', 'F')
61 #define ANI_LIST_ID RIFF_FOURCC('L', 'I', 'S', 'T')
62 #define ANI_ACON_ID RIFF_FOURCC('A', 'C', 'O', 'N')
63 #define ANI_anih_ID RIFF_FOURCC('a', 'n', 'i', 'h')
64 #define ANI_seq__ID RIFF_FOURCC('s', 'e', 'q', ' ')
65 #define ANI_fram_ID RIFF_FOURCC('f', 'r', 'a', 'm')
66 #define ANI_icon_ID RIFF_FOURCC('i', 'c', 'o', 'n')
67 #define ANI_rate_ID RIFF_FOURCC('r', 'a', 't', 'e')
69 #define ANI_FLAG_ICON 0x1
70 #define ANI_FLAG_SEQUENCE 0x2
89 CURSORICONFILEDIR icon_info
; /* animated cursor frame information */
90 BITMAPINFOHEADER bmi_header
; /* animated cursor frame header */
91 ani_data32x32x32 bmi_data
; /* animated cursor frame DIB data */
95 DWORD chunk_id
; /* ANI_anih_ID */
96 DWORD chunk_size
; /* actual size of data */
97 ani_header header
; /* animated cursor header */
101 DWORD chunk_id
; /* ANI_LIST_ID */
102 DWORD chunk_size
; /* actual size of data */
103 DWORD chunk_type
; /* ANI_fram_ID */
107 DWORD chunk_id
; /* ANI_icon_ID */
108 DWORD chunk_size
; /* actual size of data */
109 ani_frame32x32x32 data
; /* animated cursor frame */
110 } riff_icon32x32x32_t
;
113 DWORD chunk_id
; /* ANI_RIFF_ID */
114 DWORD chunk_size
; /* actual size of data */
115 DWORD chunk_type
; /* ANI_ACON_ID */
116 riff_header_t header
; /* RIFF animated cursor header */
117 riff_list_t frame_list
; /* RIFF animated cursor frame list info */
118 riff_icon32x32x32_t frames
[1]; /* array of animated cursor frames */
122 DWORD chunk_id
; /* ANI_RIFF_ID */
123 DWORD chunk_size
; /* actual size of data */
124 DWORD chunk_type
; /* ANI_ACON_ID */
125 riff_header_t header
; /* RIFF animated cursor header */
126 riff_list_t frame_list
; /* RIFF animated cursor frame list info */
127 riff_icon32x32x32_t frames
[3]; /* array of three animated cursor frames */
131 DWORD chunk_id
; /* ANI_rate_ID */
132 DWORD chunk_size
; /* actual size of data */
133 DWORD rate
[3]; /* animated cursor rate data */
137 DWORD chunk_id
; /* ANI_seq__ID */
138 DWORD chunk_size
; /* actual size of data */
139 DWORD order
[3]; /* animated cursor sequence data */
143 DWORD chunk_id
; /* ANI_RIFF_ID */
144 DWORD chunk_size
; /* actual size of data */
145 DWORD chunk_type
; /* ANI_ACON_ID */
146 riff_header_t header
; /* RIFF animated cursor header */
147 riff_seq3_t seq
; /* sequence data for three cursor frames */
148 riff_rate3_t rates
; /* rate data for three cursor frames */
149 riff_list_t frame_list
; /* RIFF animated cursor frame list info */
150 riff_icon32x32x32_t frames
[3]; /* array of three animated cursor frames */
151 } riff_cursor3_seq_t
;
153 #define EMPTY_ICON32 \
156 sizeof(ani_frame32x32x32), \
159 0x0, /* reserved */ \
160 0, /* type: icon(1), cursor(2) */ \
166 0, /* color count */ \
167 0x0, /* reserved */ \
168 16, /* x hotspot */ \
169 16, /* y hotspot */ \
170 sizeof(ani_data32x32x32), /* DIB size */ \
171 sizeof(CURSORICONFILEDIR) /* DIB offset */ \
176 sizeof(BITMAPINFOHEADER), /* structure for DIB-type data */ \
178 32*2, /* actual height times two */ \
181 BI_RGB, /* compression */ \
182 0, /* image size */ \
183 0, /* biXPelsPerMeter */ \
184 0, /* biYPelsPerMeter */ \
186 0 /* biClrImportant */ \
188 /* DIB data: left uninitialized */ \
192 riff_cursor1_t empty_anicursor
= {
194 sizeof(empty_anicursor
) - sizeof(DWORD
)*2,
207 10, /* display rate in jiffies */
208 ANI_FLAG_ICON
/* flags */
213 sizeof(riff_icon32x32x32_t
)*(1 /*frames*/) + sizeof(DWORD
),
221 riff_cursor3_t empty_anicursor3
= {
223 sizeof(empty_anicursor3
) - sizeof(DWORD
)*2,
236 0xbeef, /* display rate in jiffies */
237 ANI_FLAG_ICON
/* flags */
242 sizeof(riff_icon32x32x32_t
)*(3 /*frames*/) + sizeof(DWORD
),
252 riff_cursor3_seq_t empty_anicursor3_seq
= {
254 sizeof(empty_anicursor3_seq
) - sizeof(DWORD
)*2,
267 0xbeef, /* display rate in jiffies */
268 ANI_FLAG_ICON
|ANI_FLAG_SEQUENCE
/* flags */
273 sizeof(riff_seq3_t
) - sizeof(DWORD
)*2,
274 { 2, 0, 1} /* show frames in a uniquely identifiable order */
278 sizeof(riff_rate3_t
) - sizeof(DWORD
)*2,
279 { 0xc0de, 0xcafe, 0xbabe}
283 sizeof(riff_icon32x32x32_t
)*(3 /*frames*/) + sizeof(DWORD
),
295 static char **test_argv
;
296 static int test_argc
;
297 static HWND child
= 0;
298 static HWND parent
= 0;
299 static HANDLE child_process
;
301 #define PROC_INIT (WM_USER+1)
303 static BOOL (WINAPI
*pGetCursorInfo
)(CURSORINFO
*);
304 static BOOL (WINAPI
*pGetIconInfoExA
)(HICON
,ICONINFOEXA
*);
305 static BOOL (WINAPI
*pGetIconInfoExW
)(HICON
,ICONINFOEXW
*);
307 static const int is_win64
= (sizeof(void *) > sizeof(int));
309 static LRESULT CALLBACK
callback_child(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
316 /* Destroy the cursor. */
318 SetLastError(0xdeadbeef);
319 ret
= DestroyCursor((HCURSOR
) lParam
);
320 error
= GetLastError();
321 ok(!ret
|| broken(ret
) /* win9x */, "DestroyCursor on the active cursor succeeded.\n");
322 ok(error
== ERROR_DESTROY_OBJECT_OF_OTHER_THREAD
||
323 error
== 0xdeadbeef, /* vista */
324 "Last error: %u\n", error
);
331 return DefWindowProc(hwnd
, msg
, wParam
, lParam
);
334 static LRESULT CALLBACK
callback_parent(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
336 if (msg
== PROC_INIT
)
338 child
= (HWND
) wParam
;
342 return DefWindowProc(hwnd
, msg
, wParam
, lParam
);
345 static void do_child(void)
351 /* Register a new class. */
352 class.style
= CS_GLOBALCLASS
;
353 class.lpfnWndProc
= callback_child
;
354 class.cbClsExtra
= 0;
355 class.cbWndExtra
= 0;
356 class.hInstance
= GetModuleHandle(NULL
);
358 class.hCursor
= NULL
;
359 class.hbrBackground
= NULL
;
360 class.lpszMenuName
= NULL
;
361 class.lpszClassName
= "cursor_child";
363 SetLastError(0xdeadbeef);
364 ret
= RegisterClass(&class);
365 ok(ret
, "Failed to register window class. Error: %u\n", GetLastError());
367 /* Create a window. */
368 child
= CreateWindowA("cursor_child", "cursor_child", WS_POPUP
| WS_VISIBLE
,
369 0, 0, 200, 200, 0, 0, 0, NULL
);
370 ok(child
!= 0, "CreateWindowA failed. Error: %u\n", GetLastError());
372 /* Let the parent know our HWND. */
373 PostMessage(parent
, PROC_INIT
, (WPARAM
) child
, 0);
375 /* Receive messages. */
376 while ((ret
= GetMessage(&msg
, 0, 0, 0)))
378 ok(ret
!= -1, "GetMessage failed. Error: %u\n", GetLastError());
379 TranslateMessage(&msg
);
380 DispatchMessage(&msg
);
384 static void do_parent(void)
386 char path_name
[MAX_PATH
];
387 PROCESS_INFORMATION info
;
388 STARTUPINFOA startup
;
393 /* Register a new class. */
394 class.style
= CS_GLOBALCLASS
;
395 class.lpfnWndProc
= callback_parent
;
396 class.cbClsExtra
= 0;
397 class.cbWndExtra
= 0;
398 class.hInstance
= GetModuleHandle(NULL
);
400 class.hCursor
= NULL
;
401 class.hbrBackground
= NULL
;
402 class.lpszMenuName
= NULL
;
403 class.lpszClassName
= "cursor_parent";
405 SetLastError(0xdeadbeef);
406 ret
= RegisterClass(&class);
407 ok(ret
, "Failed to register window class. Error: %u\n", GetLastError());
409 /* Create a window. */
410 parent
= CreateWindowA("cursor_parent", "cursor_parent", WS_POPUP
| WS_VISIBLE
,
411 0, 0, 200, 200, 0, 0, 0, NULL
);
412 ok(parent
!= 0, "CreateWindowA failed. Error: %u\n", GetLastError());
414 /* Start child process. */
415 memset(&startup
, 0, sizeof(startup
));
416 startup
.cb
= sizeof(startup
);
417 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
418 startup
.wShowWindow
= SW_SHOWNORMAL
;
420 sprintf(path_name
, "%s cursoricon %lx", test_argv
[0], (INT_PTR
)parent
);
421 ok(CreateProcessA(NULL
, path_name
, NULL
, NULL
, FALSE
, 0L, NULL
, NULL
, &startup
, &info
), "CreateProcess failed.\n");
422 child_process
= info
.hProcess
;
424 /* Wait for child window handle. */
425 while ((child
== 0) && (ret
= GetMessage(&msg
, parent
, 0, 0)))
427 ok(ret
!= -1, "GetMessage failed. Error: %u\n", GetLastError());
428 TranslateMessage(&msg
);
429 DispatchMessage(&msg
);
433 static void finish_child_process(void)
435 SendMessage(child
, WM_CLOSE
, 0, 0);
436 winetest_wait_child_process( child_process
);
437 CloseHandle(child_process
);
440 static void test_child_process(void)
442 static const BYTE bmp_bits
[4096];
448 /* Create and set a dummy cursor. */
450 display_bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
453 cursorInfo
.fIcon
= FALSE
;
454 cursorInfo
.xHotspot
= 0;
455 cursorInfo
.yHotspot
= 0;
456 cursorInfo
.hbmMask
= CreateBitmap(32, 32, 1, 1, bmp_bits
);
457 cursorInfo
.hbmColor
= CreateBitmap(32, 32, 1, display_bpp
, bmp_bits
);
459 cursor
= CreateIconIndirect(&cursorInfo
);
460 ok(cursor
!= NULL
, "CreateIconIndirect returned %p.\n", cursor
);
464 /* Destroy the cursor. */
465 SendMessage(child
, WM_USER
+1, 0, (LPARAM
) cursor
);
468 static BOOL
color_match(COLORREF a
, COLORREF b
)
470 /* 5-bit accuracy is a sufficient test. This will match as long as
471 * colors are never truncated to less that 3x5-bit accuracy i.e.
473 return (a
& 0x00F8F8F8) == (b
& 0x00F8F8F8);
476 static void test_CopyImage_Check(HBITMAP bitmap
, UINT flags
, INT copyWidth
, INT copyHeight
,
477 INT expectedWidth
, INT expectedHeight
, WORD expectedDepth
, BOOL dibExpected
)
485 copy
= CopyImage(bitmap
, IMAGE_BITMAP
, copyWidth
, copyHeight
, flags
);
486 ok(copy
!= NULL
, "CopyImage() failed\n");
489 GetObject(bitmap
, sizeof(origBitmap
), &origBitmap
);
490 GetObject(copy
, sizeof(copyBitmap
), ©Bitmap
);
491 orig_is_dib
= (origBitmap
.bmBits
!= NULL
);
492 copy_is_dib
= (copyBitmap
.bmBits
!= NULL
);
494 if (copy_is_dib
&& dibExpected
495 && copyBitmap
.bmBitsPixel
== 24
496 && (expectedDepth
== 16 || expectedDepth
== 32))
498 /* Windows 95 doesn't create DIBs with a depth of 16 or 32 bit */
499 if (GetVersion() & 0x80000000)
505 if (copy_is_dib
&& !dibExpected
&& !(flags
& LR_CREATEDIBSECTION
))
507 /* It's not forbidden to create a DIB section if the flag
508 LR_CREATEDIBSECTION is absent.
509 Windows 9x does this if the bitmap has a depth that doesn't
510 match the screen depth, Windows NT doesn't */
512 expectedDepth
= origBitmap
.bmBitsPixel
;
515 ok((!(dibExpected
^ copy_is_dib
)
516 && (copyBitmap
.bmWidth
== expectedWidth
)
517 && (copyBitmap
.bmHeight
== expectedHeight
)
518 && (copyBitmap
.bmBitsPixel
== expectedDepth
)),
519 "CopyImage ((%s, %dx%d, %u bpp), %d, %d, %#x): Expected (%s, %dx%d, %u bpp), got (%s, %dx%d, %u bpp)\n",
520 orig_is_dib
? "DIB" : "DDB", origBitmap
.bmWidth
, origBitmap
.bmHeight
, origBitmap
.bmBitsPixel
,
521 copyWidth
, copyHeight
, flags
,
522 dibExpected
? "DIB" : "DDB", expectedWidth
, expectedHeight
, expectedDepth
,
523 copy_is_dib
? "DIB" : "DDB", copyBitmap
.bmWidth
, copyBitmap
.bmHeight
, copyBitmap
.bmBitsPixel
);
529 static void test_CopyImage_Bitmap(int depth
)
538 /* Create a device-independent bitmap (DIB) */
539 info
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(BITMAPINFOHEADER
) + 256 * sizeof(RGBQUAD
));
540 info
->bmiHeader
.biSize
= sizeof(info
->bmiHeader
);
541 info
->bmiHeader
.biWidth
= 2;
542 info
->bmiHeader
.biHeight
= 2;
543 info
->bmiHeader
.biPlanes
= 1;
544 info
->bmiHeader
.biBitCount
= depth
;
545 info
->bmiHeader
.biCompression
= BI_RGB
;
547 for (i
=0; i
< 256; i
++)
549 info
->bmiColors
[i
].rgbRed
= i
;
550 info
->bmiColors
[i
].rgbGreen
= i
;
551 info
->bmiColors
[i
].rgbBlue
= 255 - i
;
552 info
->bmiColors
[i
].rgbReserved
= 0;
555 dib
= CreateDIBSection(NULL
, info
, DIB_RGB_COLORS
, &bits
, NULL
, 0);
557 /* Create a device-dependent bitmap (DDB) */
558 screenDC
= GetDC(NULL
);
559 screen_depth
= GetDeviceCaps(screenDC
, BITSPIXEL
);
560 if (depth
== 1 || depth
== screen_depth
)
562 ddb
= CreateBitmap(2, 2, 1, depth
, NULL
);
568 ReleaseDC(NULL
, screenDC
);
572 test_CopyImage_Check(ddb
, 0, 0, 0, 2, 2, depth
== 1 ? 1 : screen_depth
, FALSE
);
573 test_CopyImage_Check(ddb
, 0, 0, 5, 2, 5, depth
== 1 ? 1 : screen_depth
, FALSE
);
574 test_CopyImage_Check(ddb
, 0, 5, 0, 5, 2, depth
== 1 ? 1 : screen_depth
, FALSE
);
575 test_CopyImage_Check(ddb
, 0, 5, 5, 5, 5, depth
== 1 ? 1 : screen_depth
, FALSE
);
577 test_CopyImage_Check(ddb
, LR_MONOCHROME
, 0, 0, 2, 2, 1, FALSE
);
578 test_CopyImage_Check(ddb
, LR_MONOCHROME
, 5, 0, 5, 2, 1, FALSE
);
579 test_CopyImage_Check(ddb
, LR_MONOCHROME
, 0, 5, 2, 5, 1, FALSE
);
580 test_CopyImage_Check(ddb
, LR_MONOCHROME
, 5, 5, 5, 5, 1, FALSE
);
582 test_CopyImage_Check(ddb
, LR_CREATEDIBSECTION
, 0, 0, 2, 2, depth
, TRUE
);
583 test_CopyImage_Check(ddb
, LR_CREATEDIBSECTION
, 5, 0, 5, 2, depth
, TRUE
);
584 test_CopyImage_Check(ddb
, LR_CREATEDIBSECTION
, 0, 5, 2, 5, depth
, TRUE
);
585 test_CopyImage_Check(ddb
, LR_CREATEDIBSECTION
, 5, 5, 5, 5, depth
, TRUE
);
587 /* LR_MONOCHROME is ignored if LR_CREATEDIBSECTION is present */
588 test_CopyImage_Check(ddb
, LR_MONOCHROME
| LR_CREATEDIBSECTION
, 0, 0, 2, 2, depth
, TRUE
);
589 test_CopyImage_Check(ddb
, LR_MONOCHROME
| LR_CREATEDIBSECTION
, 5, 0, 5, 2, depth
, TRUE
);
590 test_CopyImage_Check(ddb
, LR_MONOCHROME
| LR_CREATEDIBSECTION
, 0, 5, 2, 5, depth
, TRUE
);
591 test_CopyImage_Check(ddb
, LR_MONOCHROME
| LR_CREATEDIBSECTION
, 5, 5, 5, 5, depth
, TRUE
);
598 test_CopyImage_Check(dib
, 0, 0, 0, 2, 2, screen_depth
, FALSE
);
599 test_CopyImage_Check(dib
, 0, 5, 0, 5, 2, screen_depth
, FALSE
);
600 test_CopyImage_Check(dib
, 0, 0, 5, 2, 5, screen_depth
, FALSE
);
601 test_CopyImage_Check(dib
, 0, 5, 5, 5, 5, screen_depth
, FALSE
);
604 test_CopyImage_Check(dib
, LR_MONOCHROME
, 0, 0, 2, 2, 1, FALSE
);
605 test_CopyImage_Check(dib
, LR_MONOCHROME
, 5, 0, 5, 2, 1, FALSE
);
606 test_CopyImage_Check(dib
, LR_MONOCHROME
, 0, 5, 2, 5, 1, FALSE
);
607 test_CopyImage_Check(dib
, LR_MONOCHROME
, 5, 5, 5, 5, 1, FALSE
);
609 test_CopyImage_Check(dib
, LR_CREATEDIBSECTION
, 0, 0, 2, 2, depth
, TRUE
);
610 test_CopyImage_Check(dib
, LR_CREATEDIBSECTION
, 5, 0, 5, 2, depth
, TRUE
);
611 test_CopyImage_Check(dib
, LR_CREATEDIBSECTION
, 0, 5, 2, 5, depth
, TRUE
);
612 test_CopyImage_Check(dib
, LR_CREATEDIBSECTION
, 5, 5, 5, 5, depth
, TRUE
);
614 /* LR_MONOCHROME is ignored if LR_CREATEDIBSECTION is present */
615 test_CopyImage_Check(dib
, LR_MONOCHROME
| LR_CREATEDIBSECTION
, 0, 0, 2, 2, depth
, TRUE
);
616 test_CopyImage_Check(dib
, LR_MONOCHROME
| LR_CREATEDIBSECTION
, 5, 0, 5, 2, depth
, TRUE
);
617 test_CopyImage_Check(dib
, LR_MONOCHROME
| LR_CREATEDIBSECTION
, 0, 5, 2, 5, depth
, TRUE
);
618 test_CopyImage_Check(dib
, LR_MONOCHROME
| LR_CREATEDIBSECTION
, 5, 5, 5, 5, depth
, TRUE
);
624 /* Special case: A monochrome DIB is converted to a monochrome DDB if
625 the colors in the color table are black and white.
627 Skip this test on Windows 95, it always creates a monochrome DDB
630 if (!(GetVersion() & 0x80000000))
632 info
->bmiHeader
.biBitCount
= 1;
633 info
->bmiColors
[0].rgbRed
= 0xFF;
634 info
->bmiColors
[0].rgbGreen
= 0;
635 info
->bmiColors
[0].rgbBlue
= 0;
636 info
->bmiColors
[1].rgbRed
= 0;
637 info
->bmiColors
[1].rgbGreen
= 0xFF;
638 info
->bmiColors
[1].rgbBlue
= 0;
640 dib
= CreateDIBSection(NULL
, info
, DIB_RGB_COLORS
, &bits
, NULL
, 0);
641 test_CopyImage_Check(dib
, 0, 0, 0, 2, 2, screen_depth
, FALSE
);
642 test_CopyImage_Check(dib
, 0, 5, 0, 5, 2, screen_depth
, FALSE
);
643 test_CopyImage_Check(dib
, 0, 0, 5, 2, 5, screen_depth
, FALSE
);
644 test_CopyImage_Check(dib
, 0, 5, 5, 5, 5, screen_depth
, FALSE
);
647 info
->bmiHeader
.biBitCount
= 1;
648 info
->bmiColors
[0].rgbRed
= 0;
649 info
->bmiColors
[0].rgbGreen
= 0;
650 info
->bmiColors
[0].rgbBlue
= 0;
651 info
->bmiColors
[1].rgbRed
= 0xFF;
652 info
->bmiColors
[1].rgbGreen
= 0xFF;
653 info
->bmiColors
[1].rgbBlue
= 0xFF;
655 dib
= CreateDIBSection(NULL
, info
, DIB_RGB_COLORS
, &bits
, NULL
, 0);
656 test_CopyImage_Check(dib
, 0, 0, 0, 2, 2, 1, FALSE
);
657 test_CopyImage_Check(dib
, 0, 5, 0, 5, 2, 1, FALSE
);
658 test_CopyImage_Check(dib
, 0, 0, 5, 2, 5, 1, FALSE
);
659 test_CopyImage_Check(dib
, 0, 5, 5, 5, 5, 1, FALSE
);
662 info
->bmiHeader
.biBitCount
= 1;
663 info
->bmiColors
[0].rgbRed
= 0xFF;
664 info
->bmiColors
[0].rgbGreen
= 0xFF;
665 info
->bmiColors
[0].rgbBlue
= 0xFF;
666 info
->bmiColors
[1].rgbRed
= 0;
667 info
->bmiColors
[1].rgbGreen
= 0;
668 info
->bmiColors
[1].rgbBlue
= 0;
670 dib
= CreateDIBSection(NULL
, info
, DIB_RGB_COLORS
, &bits
, NULL
, 0);
671 test_CopyImage_Check(dib
, 0, 0, 0, 2, 2, 1, FALSE
);
672 test_CopyImage_Check(dib
, 0, 5, 0, 5, 2, 1, FALSE
);
673 test_CopyImage_Check(dib
, 0, 0, 5, 2, 5, 1, FALSE
);
674 test_CopyImage_Check(dib
, 0, 5, 5, 5, 5, 1, FALSE
);
679 HeapFree(GetProcessHeap(), 0, info
);
682 static void test_initial_cursor(void)
684 HCURSOR cursor
, cursor2
;
687 cursor
= GetCursor();
689 /* Check what handle GetCursor() returns if a cursor is not set yet. */
690 SetLastError(0xdeadbeef);
691 cursor2
= LoadCursor(NULL
, IDC_WAIT
);
693 ok(cursor
== cursor2
, "cursor (%p) is not IDC_WAIT (%p).\n", cursor
, cursor2
);
695 error
= GetLastError();
696 ok(error
== 0xdeadbeef, "Last error: 0x%08x\n", error
);
699 static void test_icon_info_dbg(HICON hIcon
, UINT exp_cx
, UINT exp_cy
, UINT exp_mask_cy
, UINT exp_bpp
, int line
)
703 BITMAP bmMask
, bmColor
;
705 ret
= GetIconInfo(hIcon
, &info
);
706 ok_(__FILE__
, line
)(ret
, "GetIconInfo failed\n");
708 /* CreateIcon under XP causes info.fIcon to be 0 */
709 ok_(__FILE__
, line
)(info
.xHotspot
== exp_cx
/2, "info.xHotspot = %u\n", info
.xHotspot
);
710 ok_(__FILE__
, line
)(info
.yHotspot
== exp_cy
/2, "info.yHotspot = %u\n", info
.yHotspot
);
711 ok_(__FILE__
, line
)(info
.hbmMask
!= 0, "info.hbmMask is NULL\n");
713 ret
= GetObject(info
.hbmMask
, sizeof(bmMask
), &bmMask
);
714 ok_(__FILE__
, line
)(ret
== sizeof(bmMask
), "GetObject(info.hbmMask) failed, ret %u\n", ret
);
717 ok_(__FILE__
, line
)(info
.hbmColor
== 0, "info.hbmColor should be NULL\n");
725 display_bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
728 ret
= GetObject(info
.hbmColor
, sizeof(bmColor
), &bmColor
);
729 ok_(__FILE__
, line
)(ret
== sizeof(bmColor
), "GetObject(info.hbmColor) failed, ret %u\n", ret
);
731 ok_(__FILE__
, line
)(bmColor
.bmBitsPixel
== display_bpp
/* XP */ ||
732 bmColor
.bmBitsPixel
== exp_bpp
/* Win98 */,
733 "bmColor.bmBitsPixel = %d\n", bmColor
.bmBitsPixel
);
734 ok_(__FILE__
, line
)(bmColor
.bmWidth
== exp_cx
, "bmColor.bmWidth = %d\n", bmColor
.bmWidth
);
735 ok_(__FILE__
, line
)(bmColor
.bmHeight
== exp_cy
, "bmColor.bmHeight = %d\n", bmColor
.bmHeight
);
737 ok_(__FILE__
, line
)(bmMask
.bmBitsPixel
== 1, "bmMask.bmBitsPixel = %d\n", bmMask
.bmBitsPixel
);
738 ok_(__FILE__
, line
)(bmMask
.bmWidth
== exp_cx
, "bmMask.bmWidth = %d\n", bmMask
.bmWidth
);
739 ok_(__FILE__
, line
)(bmMask
.bmHeight
== exp_mask_cy
, "bmMask.bmHeight = %d\n", bmMask
.bmHeight
);
743 ok_(__FILE__
, line
)(bmMask
.bmBitsPixel
== 1, "bmMask.bmBitsPixel = %d\n", bmMask
.bmBitsPixel
);
744 ok_(__FILE__
, line
)(bmMask
.bmWidth
== exp_cx
, "bmMask.bmWidth = %d\n", bmMask
.bmWidth
);
745 ok_(__FILE__
, line
)(bmMask
.bmHeight
== exp_mask_cy
, "bmMask.bmHeight = %d\n", bmMask
.bmHeight
);
751 memset( &infoex
, 0xcc, sizeof(infoex
) );
752 SetLastError( 0xdeadbeef );
753 infoex
.cbSize
= sizeof(infoex
) - 1;
754 ret
= pGetIconInfoExA( hIcon
, &infoex
);
755 ok_(__FILE__
, line
)(!ret
, "GetIconInfoEx succeeded\n");
756 ok_(__FILE__
, line
)(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %d\n", GetLastError());
758 SetLastError( 0xdeadbeef );
759 infoex
.cbSize
= sizeof(infoex
) + 1;
760 ret
= pGetIconInfoExA( hIcon
, &infoex
);
761 ok_(__FILE__
, line
)(!ret
, "GetIconInfoEx succeeded\n");
762 ok_(__FILE__
, line
)(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %d\n", GetLastError());
764 SetLastError( 0xdeadbeef );
765 infoex
.cbSize
= sizeof(infoex
);
766 ret
= pGetIconInfoExA( (HICON
)0xdeadbabe, &infoex
);
767 ok_(__FILE__
, line
)(!ret
, "GetIconInfoEx succeeded\n");
768 ok_(__FILE__
, line
)(GetLastError() == ERROR_INVALID_CURSOR_HANDLE
,
769 "wrong error %d\n", GetLastError());
771 infoex
.cbSize
= sizeof(infoex
);
772 ret
= pGetIconInfoExA( hIcon
, &infoex
);
773 ok_(__FILE__
, line
)(ret
, "GetIconInfoEx failed err %d\n", GetLastError());
774 ok_(__FILE__
, line
)(infoex
.wResID
== 0, "GetIconInfoEx wrong resid %x\n", infoex
.wResID
);
775 ok_(__FILE__
, line
)(infoex
.szModName
[0] == 0, "GetIconInfoEx wrong module %s\n", infoex
.szModName
);
776 ok_(__FILE__
, line
)(infoex
.szResName
[0] == 0, "GetIconInfoEx wrong name %s\n", infoex
.szResName
);
780 #define test_icon_info(a,b,c,d,e) test_icon_info_dbg((a),(b),(c),(d),(e),__LINE__)
782 static void test_CreateIcon(void)
784 static const BYTE bmp_bits
[1024];
786 HBITMAP hbmMask
, hbmColor
;
795 display_bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
797 /* these crash under XP
798 hIcon = CreateIcon(0, 16, 16, 1, 1, bmp_bits, NULL);
799 hIcon = CreateIcon(0, 16, 16, 1, 1, NULL, bmp_bits);
802 hIcon
= CreateIcon(0, 16, 16, 1, 1, bmp_bits
, bmp_bits
);
803 ok(hIcon
!= 0, "CreateIcon failed\n");
804 test_icon_info(hIcon
, 16, 16, 32, 1);
807 hIcon
= CreateIcon(0, 16, 16, 1, display_bpp
, bmp_bits
, bmp_bits
);
808 ok(hIcon
!= 0, "CreateIcon failed\n");
809 test_icon_info(hIcon
, 16, 16, 16, display_bpp
);
812 hbmMask
= CreateBitmap(16, 16, 1, 1, bmp_bits
);
813 ok(hbmMask
!= 0, "CreateBitmap failed\n");
814 hbmColor
= CreateBitmap(16, 16, 1, display_bpp
, bmp_bits
);
815 ok(hbmColor
!= 0, "CreateBitmap failed\n");
822 SetLastError(0xdeadbeaf);
823 hIcon
= CreateIconIndirect(&info
);
824 ok(!hIcon
, "CreateIconIndirect should fail\n");
825 ok(GetLastError() == 0xdeadbeaf, "wrong error %u\n", GetLastError());
831 info
.hbmColor
= hbmColor
;
832 SetLastError(0xdeadbeaf);
833 hIcon
= CreateIconIndirect(&info
);
834 ok(!hIcon
, "CreateIconIndirect should fail\n");
835 ok(GetLastError() == 0xdeadbeaf, "wrong error %u\n", GetLastError());
840 info
.hbmMask
= hbmMask
;
841 info
.hbmColor
= hbmColor
;
842 hIcon
= CreateIconIndirect(&info
);
843 ok(hIcon
!= 0, "CreateIconIndirect failed\n");
844 test_icon_info(hIcon
, 16, 16, 16, display_bpp
);
847 DeleteObject(hbmMask
);
848 DeleteObject(hbmColor
);
850 hbmMask
= CreateBitmap(16, 32, 1, 1, bmp_bits
);
851 ok(hbmMask
!= 0, "CreateBitmap failed\n");
856 info
.hbmMask
= hbmMask
;
858 SetLastError(0xdeadbeaf);
859 hIcon
= CreateIconIndirect(&info
);
860 ok(hIcon
!= 0, "CreateIconIndirect failed\n");
861 test_icon_info(hIcon
, 16, 16, 32, 1);
863 DeleteObject(hbmMask
);
865 for (i
= 0; i
<= 4; i
++)
867 hbmMask
= CreateBitmap(1, i
, 1, 1, bmp_bits
);
868 ok(hbmMask
!= 0, "CreateBitmap failed\n");
873 info
.hbmMask
= hbmMask
;
875 SetLastError(0xdeadbeaf);
876 hIcon
= CreateIconIndirect(&info
);
877 ok(hIcon
!= 0, "CreateIconIndirect failed\n");
878 test_icon_info(hIcon
, 1, i
/ 2, max(i
,1), 1);
880 DeleteObject(hbmMask
);
883 /* test creating an icon from a DIB section */
885 bmpinfo
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, FIELD_OFFSET(BITMAPINFO
,bmiColors
[256]));
886 bmpinfo
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
887 bmpinfo
->bmiHeader
.biWidth
= 32;
888 bmpinfo
->bmiHeader
.biHeight
= 32;
889 bmpinfo
->bmiHeader
.biPlanes
= 1;
890 bmpinfo
->bmiHeader
.biBitCount
= 8;
891 bmpinfo
->bmiHeader
.biCompression
= BI_RGB
;
892 hbmColor
= CreateDIBSection( hdc
, bmpinfo
, DIB_RGB_COLORS
, &bits
, NULL
, 0 );
893 ok(hbmColor
!= NULL
, "Expected a handle to the DIB\n");
895 memset( bits
, 0x55, 32 * 32 * bmpinfo
->bmiHeader
.biBitCount
/ 8 );
896 bmpinfo
->bmiHeader
.biBitCount
= 1;
897 hbmMask
= CreateDIBSection( hdc
, bmpinfo
, DIB_RGB_COLORS
, &bits
, NULL
, 0 );
898 ok(hbmMask
!= NULL
, "Expected a handle to the DIB\n");
900 memset( bits
, 0x55, 32 * 32 * bmpinfo
->bmiHeader
.biBitCount
/ 8 );
905 info
.hbmMask
= hbmColor
;
906 info
.hbmColor
= hbmMask
;
907 SetLastError(0xdeadbeaf);
908 hIcon
= CreateIconIndirect(&info
);
909 ok(hIcon
!= 0, "CreateIconIndirect failed\n");
910 test_icon_info(hIcon
, 32, 32, 32, 8);
912 DeleteObject(hbmColor
);
914 bmpinfo
->bmiHeader
.biBitCount
= 16;
915 hbmColor
= CreateDIBSection( hdc
, bmpinfo
, DIB_RGB_COLORS
, &bits
, NULL
, 0 );
916 ok(hbmColor
!= NULL
, "Expected a handle to the DIB\n");
918 memset( bits
, 0x55, 32 * 32 * bmpinfo
->bmiHeader
.biBitCount
/ 8 );
923 info
.hbmMask
= hbmColor
;
924 info
.hbmColor
= hbmMask
;
925 SetLastError(0xdeadbeaf);
926 hIcon
= CreateIconIndirect(&info
);
927 ok(hIcon
!= 0, "CreateIconIndirect failed\n");
928 test_icon_info(hIcon
, 32, 32, 32, 8);
930 DeleteObject(hbmColor
);
932 bmpinfo
->bmiHeader
.biBitCount
= 32;
933 hbmColor
= CreateDIBSection( hdc
, bmpinfo
, DIB_RGB_COLORS
, &bits
, NULL
, 0 );
934 ok(hbmColor
!= NULL
, "Expected a handle to the DIB\n");
936 memset( bits
, 0x55, 32 * 32 * bmpinfo
->bmiHeader
.biBitCount
/ 8 );
941 info
.hbmMask
= hbmColor
;
942 info
.hbmColor
= hbmMask
;
943 SetLastError(0xdeadbeaf);
944 hIcon
= CreateIconIndirect(&info
);
945 ok(hIcon
!= 0, "CreateIconIndirect failed\n");
946 test_icon_info(hIcon
, 32, 32, 32, 8);
949 DeleteObject(hbmMask
);
950 DeleteObject(hbmColor
);
951 HeapFree( GetProcessHeap(), 0, bmpinfo
);
956 /* Shamelessly ripped from dlls/oleaut32/tests/olepicture.c */
958 static unsigned char gifimage
[35] = {
959 0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
960 0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
965 static unsigned char jpgimage
[285] = {
966 0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2c,
967 0x01,0x2c,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x05,0x03,0x04,0x04,0x04,0x03,0x05,
968 0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x07,0x0c,0x08,0x07,0x07,0x07,0x07,0x0f,0x0b,
969 0x0b,0x09,0x0c,0x11,0x0f,0x12,0x12,0x11,0x0f,0x11,0x11,0x13,0x16,0x1c,0x17,0x13,
970 0x14,0x1a,0x15,0x11,0x11,0x18,0x21,0x18,0x1a,0x1d,0x1d,0x1f,0x1f,0x1f,0x13,0x17,
971 0x22,0x24,0x22,0x1e,0x24,0x1c,0x1e,0x1f,0x1e,0xff,0xdb,0x00,0x43,0x01,0x05,0x05,
972 0x05,0x07,0x06,0x07,0x0e,0x08,0x08,0x0e,0x1e,0x14,0x11,0x14,0x1e,0x1e,0x1e,0x1e,
973 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
974 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
975 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0xff,0xc0,
976 0x00,0x11,0x08,0x00,0x01,0x00,0x01,0x03,0x01,0x22,0x00,0x02,0x11,0x01,0x03,0x11,
977 0x01,0xff,0xc4,0x00,0x15,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
978 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xff,0xc4,0x00,0x14,0x10,0x01,0x00,0x00,
979 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xc4,
980 0x00,0x14,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
981 0x00,0x00,0x00,0x00,0xff,0xc4,0x00,0x14,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
982 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xda,0x00,0x0c,0x03,0x01,
983 0x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xb2,0xc0,0x07,0xff,0xd9
987 static unsigned char pngimage
[285] = {
988 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
989 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,
990 0xde,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,
991 0x13,0x01,0x00,0x9a,0x9c,0x18,0x00,0x00,0x00,0x07,0x74,0x49,0x4d,0x45,0x07,0xd5,
992 0x06,0x03,0x0f,0x07,0x2d,0x12,0x10,0xf0,0xfd,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,
993 0x54,0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,
994 0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
997 /* 1x1 pixel bmp with gap between palette and bitmap. Correct bitmap contains only
998 zeroes, gap is 0xFF. */
999 static unsigned char bmpimage
[70] = {
1000 0x42,0x4d,0x46,0x00,0x00,0x00,0xDE,0xAD,0xBE,0xEF,0x42,0x00,0x00,0x00,0x28,0x00,
1001 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
1002 0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
1003 0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0x55,0x55,0x55,0x00,0xFF,0xFF,
1004 0xFF,0xFF,0x00,0x00,0x00,0x00
1007 /* 1x1 pixel bmp using BITMAPCOREHEADER */
1008 static unsigned char bmpcoreimage
[38] = {
1009 0x42,0x4d,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x0c,0x00,
1010 0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xff,0xff,0xff,0x00,0x55,0x55,
1011 0x55,0x00,0x00,0x00,0x00,0x00
1015 static unsigned char gif4pixel
[42] = {
1016 0x47,0x49,0x46,0x38,0x37,0x61,0x02,0x00,0x02,0x00,0xa1,0x00,0x00,0x00,0x00,0x00,
1017 0x39,0x62,0xfc,0xff,0x1a,0xe5,0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x02,0x00,
1018 0x02,0x00,0x00,0x02,0x03,0x14,0x16,0x05,0x00,0x3b
1021 static const DWORD biSize_tests
[] = {
1023 sizeof(BITMAPCOREHEADER
) - 1,
1024 sizeof(BITMAPCOREHEADER
) + 1,
1025 sizeof(BITMAPINFOHEADER
) - 1,
1026 sizeof(BITMAPINFOHEADER
) + 1,
1027 sizeof(BITMAPV4HEADER
) - 1,
1028 sizeof(BITMAPV4HEADER
) + 1,
1029 sizeof(BITMAPV5HEADER
) - 1,
1030 sizeof(BITMAPV5HEADER
) + 1,
1031 (sizeof(BITMAPCOREHEADER
) + sizeof(BITMAPINFOHEADER
)) / 2,
1032 (sizeof(BITMAPV4HEADER
) + sizeof(BITMAPV5HEADER
)) / 2,
1037 #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
1039 static void test_LoadImageBitmap(const char * test_desc
, HBITMAP hbm
)
1043 DWORD ret
, pixel
= 0;
1044 HDC hdc
= GetDC(NULL
);
1046 ret
= GetObject(hbm
, sizeof(bm
), &bm
);
1047 ok(ret
== sizeof(bm
), "GetObject returned %d\n", ret
);
1049 memset(&bmi
, 0, sizeof(bmi
));
1050 bmi
.bmiHeader
.biSize
= sizeof(bmi
.bmiHeader
);
1051 bmi
.bmiHeader
.biWidth
= bm
.bmWidth
;
1052 bmi
.bmiHeader
.biHeight
= bm
.bmHeight
;
1053 bmi
.bmiHeader
.biPlanes
= 1;
1054 bmi
.bmiHeader
.biBitCount
= 24;
1055 bmi
.bmiHeader
.biCompression
= BI_RGB
;
1056 ret
= GetDIBits(hdc
, hbm
, 0, bm
.bmHeight
, &pixel
, &bmi
, DIB_RGB_COLORS
);
1057 ok(ret
== bm
.bmHeight
, "%s: %d lines were converted, not %d\n", test_desc
, ret
, bm
.bmHeight
);
1059 ok(color_match(pixel
, 0x00ffffff), "%s: Pixel is 0x%08x\n", test_desc
, pixel
);
1062 static void test_LoadImageFile(const char * test_desc
, unsigned char * image_data
,
1063 unsigned int image_size
, const char * ext
, BOOL expect_success
)
1067 DWORD error
, bytes_written
;
1070 strcpy(filename
, "test.");
1071 strcat(filename
, ext
);
1073 /* Create the test image. */
1074 handle
= CreateFileA(filename
, GENERIC_READ
|GENERIC_WRITE
, 0, NULL
, CREATE_NEW
,
1075 FILE_ATTRIBUTE_NORMAL
, NULL
);
1076 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateFileA failed. %u\n", GetLastError());
1077 ret
= WriteFile(handle
, image_data
, image_size
, &bytes_written
, NULL
);
1078 ok(ret
&& bytes_written
== image_size
, "test file created improperly.\n");
1079 CloseHandle(handle
);
1081 /* Load as cursor. For all tested formats, this should fail */
1082 SetLastError(0xdeadbeef);
1083 handle
= LoadImageA(NULL
, filename
, IMAGE_CURSOR
, 0, 0, LR_LOADFROMFILE
);
1084 ok(handle
== NULL
, "%s: IMAGE_CURSOR succeeded incorrectly.\n", test_desc
);
1085 error
= GetLastError();
1087 broken(error
== 0xdeadbeef) || /* Win9x */
1088 broken(error
== ERROR_BAD_PATHNAME
), /* Win98, WinMe */
1089 "Last error: %u\n", error
);
1090 if (handle
!= NULL
) DestroyCursor(handle
);
1092 /* Load as icon. For all tested formats, this should fail */
1093 SetLastError(0xdeadbeef);
1094 handle
= LoadImageA(NULL
, filename
, IMAGE_ICON
, 0, 0, LR_LOADFROMFILE
);
1095 ok(handle
== NULL
, "%s: IMAGE_ICON succeeded incorrectly.\n", test_desc
);
1096 error
= GetLastError();
1098 broken(error
== 0xdeadbeef) || /* Win9x */
1099 broken(error
== ERROR_BAD_PATHNAME
), /* Win98, WinMe */
1100 "Last error: %u\n", error
);
1101 if (handle
!= NULL
) DestroyIcon(handle
);
1103 /* Load as bitmap. Should succeed for correct bmp, fail for everything else */
1104 SetLastError(0xdeadbeef);
1105 handle
= LoadImageA(NULL
, filename
, IMAGE_BITMAP
, 0, 0, LR_LOADFROMFILE
);
1106 error
= GetLastError();
1108 error
== 0xdeadbeef, /* Win9x, WinMe */
1109 "Last error: %u\n", error
);
1111 if (expect_success
) {
1112 ok(handle
!= NULL
, "%s: IMAGE_BITMAP failed.\n", test_desc
);
1113 if (handle
!= NULL
) test_LoadImageBitmap(test_desc
, handle
);
1115 else ok(handle
== NULL
, "%s: IMAGE_BITMAP succeeded incorrectly.\n", test_desc
);
1117 if (handle
!= NULL
) DeleteObject(handle
);
1118 DeleteFileA(filename
);
1121 static void test_LoadImage(void)
1125 DWORD error
, bytes_written
;
1126 CURSORICONFILEDIR
*icon_data
;
1127 CURSORICONFILEDIRENTRY
*icon_entry
;
1128 BITMAPINFOHEADER
*icon_header
, *bitmap_header
;
1132 #define ICON_WIDTH 32
1133 #define ICON_HEIGHT 32
1134 #define ICON_AND_SIZE (ICON_WIDTH*ICON_HEIGHT/8)
1137 (sizeof(CURSORICONFILEDIR) + sizeof(BITMAPINFOHEADER) \
1138 + ICON_AND_SIZE + ICON_AND_SIZE*ICON_BPP)
1140 /* Set icon data. */
1141 icon_data
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, ICON_SIZE
);
1142 icon_data
->idReserved
= 0;
1143 icon_data
->idType
= 1;
1144 icon_data
->idCount
= 1;
1146 icon_entry
= icon_data
->idEntries
;
1147 icon_entry
->bWidth
= ICON_WIDTH
;
1148 icon_entry
->bHeight
= ICON_HEIGHT
;
1149 icon_entry
->bColorCount
= 0;
1150 icon_entry
->bReserved
= 0;
1151 icon_entry
->xHotspot
= 1;
1152 icon_entry
->yHotspot
= 1;
1153 icon_entry
->dwDIBSize
= ICON_SIZE
- sizeof(CURSORICONFILEDIR
);
1154 icon_entry
->dwDIBOffset
= sizeof(CURSORICONFILEDIR
);
1156 icon_header
= (BITMAPINFOHEADER
*) ((BYTE
*) icon_data
+ icon_entry
->dwDIBOffset
);
1157 icon_header
->biSize
= sizeof(BITMAPINFOHEADER
);
1158 icon_header
->biWidth
= ICON_WIDTH
;
1159 icon_header
->biHeight
= ICON_HEIGHT
*2;
1160 icon_header
->biPlanes
= 1;
1161 icon_header
->biBitCount
= ICON_BPP
;
1162 icon_header
->biSizeImage
= 0; /* Uncompressed bitmap. */
1164 /* Create the icon. */
1165 handle
= CreateFileA("icon.ico", GENERIC_READ
|GENERIC_WRITE
, 0, NULL
, CREATE_NEW
,
1166 FILE_ATTRIBUTE_NORMAL
, NULL
);
1167 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateFileA failed. %u\n", GetLastError());
1168 ret
= WriteFile(handle
, icon_data
, ICON_SIZE
, &bytes_written
, NULL
);
1169 ok(ret
&& bytes_written
== ICON_SIZE
, "icon.ico created improperly.\n");
1170 CloseHandle(handle
);
1172 /* Test loading an icon as a cursor. */
1173 SetLastError(0xdeadbeef);
1174 handle
= LoadImageA(NULL
, "icon.ico", IMAGE_CURSOR
, 0, 0, LR_LOADFROMFILE
);
1175 ok(handle
!= NULL
, "LoadImage() failed.\n");
1176 error
= GetLastError();
1178 broken(error
== 0xdeadbeef) || /* Win9x */
1179 broken(error
== ERROR_BAD_PATHNAME
), /* Win98, WinMe */
1180 "Last error: %u\n", error
);
1182 /* Test the icon information. */
1183 SetLastError(0xdeadbeef);
1184 ret
= GetIconInfo(handle
, &icon_info
);
1185 ok(ret
, "GetIconInfo() failed.\n");
1186 error
= GetLastError();
1187 ok(error
== 0xdeadbeef, "Last error: %u\n", error
);
1191 ok(icon_info
.fIcon
== FALSE
, "fIcon != FALSE.\n");
1192 ok(icon_info
.xHotspot
== 1, "xHotspot is %u.\n", icon_info
.xHotspot
);
1193 ok(icon_info
.yHotspot
== 1, "yHotspot is %u.\n", icon_info
.yHotspot
);
1194 ok(icon_info
.hbmColor
!= NULL
|| broken(!icon_info
.hbmColor
) /* no color cursor support */,
1196 ok(icon_info
.hbmMask
!= NULL
, "No hbmMask!\n");
1199 if (pGetIconInfoExA
)
1202 infoex
.cbSize
= sizeof(infoex
);
1203 ret
= pGetIconInfoExA( handle
, &infoex
);
1204 ok( ret
, "GetIconInfoEx failed err %d\n", GetLastError() );
1205 ok( infoex
.wResID
== 0, "GetIconInfoEx wrong resid %x\n", infoex
.wResID
);
1206 ok( infoex
.szModName
[0] == 0, "GetIconInfoEx wrong module %s\n", infoex
.szModName
);
1207 ok( infoex
.szResName
[0] == 0, "GetIconInfoEx wrong name %s\n", infoex
.szResName
);
1209 else win_skip( "GetIconInfoEx not available\n" );
1212 SetLastError(0xdeadbeef);
1213 ret
= DestroyCursor(handle
);
1214 ok(ret
, "DestroyCursor() failed.\n");
1215 error
= GetLastError();
1216 ok(error
== 0xdeadbeef, "Last error: %u\n", error
);
1218 HeapFree(GetProcessHeap(), 0, icon_data
);
1219 DeleteFileA("icon.ico");
1221 /* Test a system icon */
1222 handle
= LoadIcon( 0, IDI_HAND
);
1223 ok(handle
!= NULL
, "LoadImage() failed.\n");
1224 if (pGetIconInfoExA
)
1226 ICONINFOEXA infoexA
;
1227 ICONINFOEXW infoexW
;
1228 infoexA
.cbSize
= sizeof(infoexA
);
1229 ret
= pGetIconInfoExA( handle
, &infoexA
);
1230 ok( ret
, "GetIconInfoEx failed err %d\n", GetLastError() );
1231 ok( infoexA
.wResID
== (UINT_PTR
)IDI_HAND
, "GetIconInfoEx wrong resid %x\n", infoexA
.wResID
);
1232 /* the A version is broken on 64-bit, it truncates the string after the first char */
1233 if (is_win64
&& infoexA
.szModName
[0] && infoexA
.szModName
[1] == 0)
1234 trace( "GetIconInfoExA broken on Win64\n" );
1236 ok( GetModuleHandleA(infoexA
.szModName
) == GetModuleHandleA("user32.dll"),
1237 "GetIconInfoEx wrong module %s\n", infoexA
.szModName
);
1238 ok( infoexA
.szResName
[0] == 0, "GetIconInfoEx wrong name %s\n", infoexA
.szResName
);
1239 infoexW
.cbSize
= sizeof(infoexW
);
1240 ret
= pGetIconInfoExW( handle
, &infoexW
);
1241 ok( ret
, "GetIconInfoEx failed err %d\n", GetLastError() );
1242 ok( infoexW
.wResID
== (UINT_PTR
)IDI_HAND
, "GetIconInfoEx wrong resid %x\n", infoexW
.wResID
);
1243 ok( GetModuleHandleW(infoexW
.szModName
) == GetModuleHandleA("user32.dll"),
1244 "GetIconInfoEx wrong module %s\n", wine_dbgstr_w(infoexW
.szModName
) );
1245 ok( infoexW
.szResName
[0] == 0, "GetIconInfoEx wrong name %s\n", wine_dbgstr_w(infoexW
.szResName
) );
1247 SetLastError(0xdeadbeef);
1248 DestroyIcon(handle
);
1250 test_LoadImageFile("BMP", bmpimage
, sizeof(bmpimage
), "bmp", 1);
1251 test_LoadImageFile("BMP (coreinfo)", bmpcoreimage
, sizeof(bmpcoreimage
), "bmp", 1);
1252 test_LoadImageFile("GIF", gifimage
, sizeof(gifimage
), "gif", 0);
1253 test_LoadImageFile("GIF (2x2 pixel)", gif4pixel
, sizeof(gif4pixel
), "gif", 0);
1254 test_LoadImageFile("JPG", jpgimage
, sizeof(jpgimage
), "jpg", 0);
1255 test_LoadImageFile("PNG", pngimage
, sizeof(pngimage
), "png", 0);
1257 /* Check failure for broken BMP images */
1258 bitmap_header
= (BITMAPINFOHEADER
*)(bmpimage
+ sizeof(BITMAPFILEHEADER
));
1260 bitmap_header
->biHeight
= 65536;
1261 test_LoadImageFile("BMP (too high)", bmpimage
, sizeof(bmpimage
), "bmp", 0);
1262 bitmap_header
->biHeight
= 1;
1264 bitmap_header
->biWidth
= 65536;
1265 test_LoadImageFile("BMP (too wide)", bmpimage
, sizeof(bmpimage
), "bmp", 0);
1266 bitmap_header
->biWidth
= 1;
1268 for (i
= 0; i
< ARRAY_SIZE(biSize_tests
); i
++) {
1269 bitmap_header
->biSize
= biSize_tests
[i
];
1270 test_LoadImageFile("BMP (broken biSize)", bmpimage
, sizeof(bmpimage
), "bmp", 0);
1272 bitmap_header
->biSize
= sizeof(BITMAPINFOHEADER
);
1277 static void test_CreateIconFromResource(void)
1282 BITMAPINFOHEADER
*icon_header
;
1286 #define ICON_RES_WIDTH 32
1287 #define ICON_RES_HEIGHT 32
1288 #define ICON_RES_AND_SIZE (ICON_WIDTH*ICON_HEIGHT/8)
1289 #define ICON_RES_BPP 32
1290 #define ICON_RES_SIZE \
1291 (sizeof(BITMAPINFOHEADER) + ICON_AND_SIZE + ICON_AND_SIZE*ICON_BPP)
1292 #define CRSR_RES_SIZE (2*sizeof(INT16) + ICON_RES_SIZE)
1294 /* Set icon data. */
1295 hotspot
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, CRSR_RES_SIZE
);
1297 /* Cursor resources have an extra hotspot, icon resources not. */
1301 icon_header
= (BITMAPINFOHEADER
*) (hotspot
+ 2);
1302 icon_header
->biSize
= sizeof(BITMAPINFOHEADER
);
1303 icon_header
->biWidth
= ICON_WIDTH
;
1304 icon_header
->biHeight
= ICON_HEIGHT
*2;
1305 icon_header
->biPlanes
= 1;
1306 icon_header
->biBitCount
= ICON_BPP
;
1307 icon_header
->biSizeImage
= 0; /* Uncompressed bitmap. */
1309 /* Test creating a cursor. */
1310 SetLastError(0xdeadbeef);
1311 handle
= CreateIconFromResource((PBYTE
) hotspot
, CRSR_RES_SIZE
, FALSE
, 0x00030000);
1312 ok(handle
!= NULL
, "Create cursor failed.\n");
1314 /* Test the icon information. */
1315 SetLastError(0xdeadbeef);
1316 ret
= GetIconInfo(handle
, &icon_info
);
1317 ok(ret
, "GetIconInfo() failed.\n");
1318 error
= GetLastError();
1319 ok(error
== 0xdeadbeef, "Last error: %u\n", error
);
1323 ok(icon_info
.fIcon
== FALSE
, "fIcon != FALSE.\n");
1324 ok(icon_info
.xHotspot
== 3, "xHotspot is %u.\n", icon_info
.xHotspot
);
1325 ok(icon_info
.yHotspot
== 3, "yHotspot is %u.\n", icon_info
.yHotspot
);
1326 ok(icon_info
.hbmColor
!= NULL
|| broken(!icon_info
.hbmColor
) /* no color cursor support */,
1328 ok(icon_info
.hbmMask
!= NULL
, "No hbmMask!\n");
1331 if (pGetIconInfoExA
)
1334 infoex
.cbSize
= sizeof(infoex
);
1335 ret
= pGetIconInfoExA( handle
, &infoex
);
1336 ok( ret
, "GetIconInfoEx failed err %d\n", GetLastError() );
1337 ok( infoex
.wResID
== 0, "GetIconInfoEx wrong resid %x\n", infoex
.wResID
);
1338 ok( infoex
.szModName
[0] == 0, "GetIconInfoEx wrong module %s\n", infoex
.szModName
);
1339 ok( infoex
.szResName
[0] == 0, "GetIconInfoEx wrong name %s\n", infoex
.szResName
);
1343 SetLastError(0xdeadbeef);
1344 ret
= DestroyCursor(handle
);
1345 ok(ret
, "DestroyCursor() failed.\n");
1346 error
= GetLastError();
1347 ok(error
== 0xdeadbeef, "Last error: %u\n", error
);
1349 /* Test creating an icon. */
1350 SetLastError(0xdeadbeef);
1351 handle
= CreateIconFromResource((PBYTE
) icon_header
, ICON_RES_SIZE
, TRUE
,
1353 ok(handle
!= NULL
, "Create icon failed.\n");
1355 /* Test the icon information. */
1356 SetLastError(0xdeadbeef);
1357 ret
= GetIconInfo(handle
, &icon_info
);
1358 ok(ret
, "GetIconInfo() failed.\n");
1359 error
= GetLastError();
1360 ok(error
== 0xdeadbeef, "Last error: %u\n", error
);
1364 ok(icon_info
.fIcon
== TRUE
, "fIcon != TRUE.\n");
1365 /* Icons always have hotspot in the middle */
1366 ok(icon_info
.xHotspot
== ICON_WIDTH
/2, "xHotspot is %u.\n", icon_info
.xHotspot
);
1367 ok(icon_info
.yHotspot
== ICON_HEIGHT
/2, "yHotspot is %u.\n", icon_info
.yHotspot
);
1368 ok(icon_info
.hbmColor
!= NULL
, "No hbmColor!\n");
1369 ok(icon_info
.hbmMask
!= NULL
, "No hbmMask!\n");
1373 SetLastError(0xdeadbeef);
1374 ret
= DestroyCursor(handle
);
1375 ok(ret
, "DestroyCursor() failed.\n");
1376 error
= GetLastError();
1377 ok(error
== 0xdeadbeef, "Last error: %u\n", error
);
1379 /* Rejection of NULL pointer crashes at least on WNT4WSSP6, W2KPROSP4, WXPPROSP3
1381 * handle = CreateIconFromResource(NULL, ICON_RES_SIZE, TRUE, 0x00030000);
1382 * ok(handle == NULL, "Invalid pointer accepted (%p)\n", handle);
1384 HeapFree(GetProcessHeap(), 0, hotspot
);
1386 /* Test creating an animated cursor. */
1387 empty_anicursor
.frames
[0].data
.icon_info
.idType
= 2; /* type: cursor */
1388 empty_anicursor
.frames
[0].data
.icon_info
.idEntries
[0].xHotspot
= 3;
1389 empty_anicursor
.frames
[0].data
.icon_info
.idEntries
[0].yHotspot
= 3;
1390 handle
= CreateIconFromResource((PBYTE
) &empty_anicursor
, sizeof(empty_anicursor
), FALSE
, 0x00030000);
1391 ok(handle
!= NULL
, "Create cursor failed.\n");
1393 /* Test the animated cursor's information. */
1394 SetLastError(0xdeadbeef);
1395 ret
= GetIconInfo(handle
, &icon_info
);
1396 ok(ret
, "GetIconInfo() failed.\n");
1397 error
= GetLastError();
1398 ok(error
== 0xdeadbeef, "Last error: %u\n", error
);
1402 ok(icon_info
.fIcon
== FALSE
, "fIcon != FALSE.\n");
1403 ok(icon_info
.xHotspot
== 3, "xHotspot is %u.\n", icon_info
.xHotspot
);
1404 ok(icon_info
.yHotspot
== 3, "yHotspot is %u.\n", icon_info
.yHotspot
);
1405 ok(icon_info
.hbmColor
!= NULL
|| broken(!icon_info
.hbmColor
) /* no color cursor support */,
1407 ok(icon_info
.hbmMask
!= NULL
, "No hbmMask!\n");
1411 SetLastError(0xdeadbeef);
1412 ret
= DestroyCursor(handle
);
1413 ok(ret
, "DestroyCursor() failed.\n");
1414 error
= GetLastError();
1415 ok(error
== 0xdeadbeef, "Last error: %u\n", error
);
1418 static int check_cursor_data( HDC hdc
, HCURSOR hCursor
, void *data
, int length
)
1426 ret
= GetIconInfo( hCursor
, &iinfo
);
1427 ok(ret
, "GetIconInfo() failed\n");
1430 info
= HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO
, bmiColors
[256] ));
1431 ok(info
!= NULL
, "HeapAlloc() failed\n");
1432 if (!info
) return 0;
1434 info
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1435 info
->bmiHeader
.biWidth
= 32;
1436 info
->bmiHeader
.biHeight
= 32;
1437 info
->bmiHeader
.biPlanes
= 1;
1438 info
->bmiHeader
.biBitCount
= 32;
1439 info
->bmiHeader
.biCompression
= BI_RGB
;
1440 info
->bmiHeader
.biSizeImage
= 32 * 32 * 4;
1441 info
->bmiHeader
.biXPelsPerMeter
= 0;
1442 info
->bmiHeader
.biYPelsPerMeter
= 0;
1443 info
->bmiHeader
.biClrUsed
= 0;
1444 info
->bmiHeader
.biClrImportant
= 0;
1445 image
= HeapAlloc( GetProcessHeap(), 0, info
->bmiHeader
.biSizeImage
);
1446 ok(image
!= NULL
, "HeapAlloc() failed\n");
1447 if (!image
) goto cleanup
;
1448 ret
= GetDIBits( hdc
, iinfo
.hbmColor
, 0, 32, image
, info
, DIB_RGB_COLORS
);
1449 ok(ret
, "GetDIBits() failed\n");
1450 for (i
= 0; ret
&& i
< length
/ sizeof(COLORREF
); i
++)
1452 ret
= color_match( ((COLORREF
*)data
)[i
], ((COLORREF
*)image
)[i
] );
1453 ok(ret
, "%04x: Expected 0x%x, actually 0x%x\n", i
, ((COLORREF
*)data
)[i
], ((COLORREF
*)image
)[i
] );
1456 HeapFree( GetProcessHeap(), 0, image
);
1457 HeapFree( GetProcessHeap(), 0, info
);
1461 static HCURSOR (WINAPI
*pGetCursorFrameInfo
)(HCURSOR hCursor
, DWORD unk1
, DWORD istep
, DWORD
*rate
, DWORD
*steps
);
1462 static void test_GetCursorFrameInfo(void)
1464 DWORD frame_identifier
[] = { 0x10Ad, 0xc001, 0x1c05 };
1465 HBITMAP bmp
= NULL
, bmpOld
= NULL
;
1467 BITMAPINFOHEADER
*icon_header
;
1468 BITMAPINFO bitmapInfo
;
1476 if (!pGetCursorFrameInfo
)
1478 win_skip( "GetCursorFrameInfo not supported, skipping tests.\n" );
1482 hdc
= CreateCompatibleDC(0);
1483 ok(hdc
!= 0, "CreateCompatibleDC(0) failed to return a valid DC\n");
1487 memset(&bitmapInfo
, 0, sizeof(bitmapInfo
));
1488 bitmapInfo
.bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1489 bitmapInfo
.bmiHeader
.biWidth
= 3;
1490 bitmapInfo
.bmiHeader
.biHeight
= 3;
1491 bitmapInfo
.bmiHeader
.biBitCount
= 32;
1492 bitmapInfo
.bmiHeader
.biPlanes
= 1;
1493 bitmapInfo
.bmiHeader
.biCompression
= BI_RGB
;
1494 bitmapInfo
.bmiHeader
.biSizeImage
= sizeof(UINT32
);
1495 bmp
= CreateDIBSection(hdc
, &bitmapInfo
, DIB_RGB_COLORS
, &bits
, NULL
, 0);
1496 ok (bmp
&& bits
, "CreateDIBSection failed to return a valid bitmap and buffer\n");
1499 bmpOld
= SelectObject(hdc
, bmp
);
1501 #define ICON_RES_WIDTH 32
1502 #define ICON_RES_HEIGHT 32
1503 #define ICON_RES_AND_SIZE (ICON_WIDTH*ICON_HEIGHT/8)
1504 #define ICON_RES_BPP 32
1505 #define ICON_RES_SIZE \
1506 (sizeof(BITMAPINFOHEADER) + ICON_AND_SIZE + ICON_AND_SIZE*ICON_BPP)
1507 #define CRSR_RES_SIZE (2*sizeof(INT16) + ICON_RES_SIZE)
1509 /* Set icon data. */
1510 hotspot
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, CRSR_RES_SIZE
);
1512 /* Cursor resources have an extra hotspot, icon resources not. */
1516 icon_header
= (BITMAPINFOHEADER
*) (hotspot
+ 2);
1517 icon_header
->biSize
= sizeof(BITMAPINFOHEADER
);
1518 icon_header
->biWidth
= ICON_WIDTH
;
1519 icon_header
->biHeight
= ICON_HEIGHT
*2;
1520 icon_header
->biPlanes
= 1;
1521 icon_header
->biBitCount
= ICON_BPP
;
1522 icon_header
->biSizeImage
= 0; /* Uncompressed bitmap. */
1524 /* Creating a static cursor. */
1525 SetLastError(0xdeadbeef);
1526 h1
= CreateIconFromResource((PBYTE
) hotspot
, CRSR_RES_SIZE
, FALSE
, 0x00030000);
1527 ok(h1
!= NULL
, "Create cursor failed (error = %d).\n", GetLastError());
1529 /* Check GetCursorFrameInfo behavior on a static cursor */
1530 rate
= steps
= 0xdead;
1531 h2
= pGetCursorFrameInfo(h1
, 0xdead, 0xdead, &rate
, &steps
);
1532 ok(h1
== h2
, "GetCursorFrameInfo() failed: (%p != %p).\n", h1
, h2
);
1533 ok(rate
== 0, "GetCursorFrameInfo() unexpected param 4 value (0x%x != 0x0).\n", rate
);
1534 ok(steps
== 1, "GetCursorFrameInfo() unexpected param 5 value (%d != 1).\n", steps
);
1536 /* Clean up static cursor. */
1537 SetLastError(0xdeadbeef);
1538 ret
= DestroyCursor(h1
);
1539 ok(ret
, "DestroyCursor() failed (error = %d).\n", GetLastError());
1541 /* Creating a single-frame animated cursor. */
1542 empty_anicursor
.frames
[0].data
.icon_info
.idType
= 2; /* type: cursor */
1543 empty_anicursor
.frames
[0].data
.icon_info
.idEntries
[0].xHotspot
= 3;
1544 empty_anicursor
.frames
[0].data
.icon_info
.idEntries
[0].yHotspot
= 3;
1545 memcpy( &empty_anicursor
.frames
[0].data
.bmi_data
.data
[0], &frame_identifier
[0], sizeof(DWORD
) );
1546 SetLastError(0xdeadbeef);
1547 h1
= CreateIconFromResource((PBYTE
) &empty_anicursor
, sizeof(empty_anicursor
), FALSE
, 0x00030000);
1548 ok(h1
!= NULL
, "Create cursor failed (error = %d).\n", GetLastError());
1550 /* Check GetCursorFrameInfo behavior on a single-frame animated cursor */
1551 rate
= steps
= 0xdead;
1552 h2
= pGetCursorFrameInfo(h1
, 0xdead, 0, &rate
, &steps
);
1553 ok(h1
== h2
, "GetCursorFrameInfo() failed: (%p != %p).\n", h1
, h2
);
1554 ret
= check_cursor_data( hdc
, h2
, &frame_identifier
[0], sizeof(DWORD
) );
1555 ok(ret
, "GetCursorFrameInfo() returned wrong cursor data for frame 0.\n");
1556 ok(rate
== 0x0, "GetCursorFrameInfo() unexpected param 4 value (0x%x != 0x0).\n", rate
);
1557 ok(steps
== empty_anicursor
.header
.header
.num_steps
,
1558 "GetCursorFrameInfo() unexpected param 5 value (%d != 1).\n", steps
);
1560 /* Clean up single-frame animated cursor. */
1561 SetLastError(0xdeadbeef);
1562 ret
= DestroyCursor(h1
);
1563 ok(ret
, "DestroyCursor() failed (error = %d).\n", GetLastError());
1565 /* Creating a multi-frame animated cursor. */
1566 for (i
=0; i
<empty_anicursor3
.header
.header
.num_frames
; i
++)
1568 empty_anicursor3
.frames
[i
].data
.icon_info
.idType
= 2; /* type: cursor */
1569 empty_anicursor3
.frames
[i
].data
.icon_info
.idEntries
[0].xHotspot
= 3;
1570 empty_anicursor3
.frames
[i
].data
.icon_info
.idEntries
[0].yHotspot
= 3;
1571 memcpy( &empty_anicursor3
.frames
[i
].data
.bmi_data
.data
[0], &frame_identifier
[i
], sizeof(DWORD
) );
1573 SetLastError(0xdeadbeef);
1574 h1
= CreateIconFromResource((PBYTE
) &empty_anicursor3
, sizeof(empty_anicursor3
), FALSE
, 0x00030000);
1575 ok(h1
!= NULL
, "Create cursor failed (error = %d).\n", GetLastError());
1577 /* Check number of steps in multi-frame animated cursor */
1579 while (DrawIconEx(hdc
, 0, 0, h1
, 32, 32, i
, NULL
, DI_NORMAL
))
1581 ok(i
== empty_anicursor3
.header
.header
.num_steps
,
1582 "Unexpected number of steps in cursor (%d != %d)\n",
1583 i
, empty_anicursor3
.header
.header
.num_steps
);
1585 /* Check GetCursorFrameInfo behavior on a multi-frame animated cursor */
1586 for (i
=0; i
<empty_anicursor3
.header
.header
.num_frames
; i
++)
1588 rate
= steps
= 0xdead;
1589 h2
= pGetCursorFrameInfo(h1
, 0xdead, i
, &rate
, &steps
);
1590 ok(h1
!= h2
&& h2
!= 0, "GetCursorFrameInfo() failed for cursor %p: (%p, %p).\n", h1
, h1
, h2
);
1591 ret
= check_cursor_data( hdc
, h2
, &frame_identifier
[i
], sizeof(DWORD
) );
1592 ok(ret
, "GetCursorFrameInfo() returned wrong cursor data for frame %d.\n", i
);
1593 ok(rate
== empty_anicursor3
.header
.header
.display_rate
,
1594 "GetCursorFrameInfo() unexpected param 4 value (0x%x != 0x%x).\n",
1595 rate
, empty_anicursor3
.header
.header
.display_rate
);
1596 ok(steps
== empty_anicursor3
.header
.header
.num_steps
,
1597 "GetCursorFrameInfo() unexpected param 5 value (%d != %d).\n",
1598 steps
, empty_anicursor3
.header
.header
.num_steps
);
1601 /* Check GetCursorFrameInfo behavior on rate 3 of a multi-frame animated cursor */
1602 rate
= steps
= 0xdead;
1603 h2
= pGetCursorFrameInfo(h1
, 0xdead, 3, &rate
, &steps
);
1604 ok(h2
== 0, "GetCursorFrameInfo() failed for cursor %p: (%p != 0).\n", h1
, h2
);
1605 ok(rate
== 0xdead || broken(rate
== empty_anicursor3
.header
.header
.display_rate
) /*win2k*/
1606 || broken(rate
== ~0) /*win2k (sporadic)*/,
1607 "GetCursorFrameInfo() unexpected param 4 value (0x%x != 0xdead).\n", rate
);
1608 ok(steps
== 0xdead || broken(steps
== empty_anicursor3
.header
.header
.num_steps
) /*win2k*/
1609 || broken(steps
== 0) /*win2k (sporadic)*/,
1610 "GetCursorFrameInfo() unexpected param 5 value (0x%x != 0xdead).\n", steps
);
1612 /* Clean up multi-frame animated cursor. */
1613 SetLastError(0xdeadbeef);
1614 ret
= DestroyCursor(h1
);
1615 ok(ret
, "DestroyCursor() failed (error = %d).\n", GetLastError());
1617 /* Create a multi-frame animated cursor with num_steps == 1 */
1618 empty_anicursor3
.header
.header
.num_steps
= 1;
1619 SetLastError(0xdeadbeef);
1620 h1
= CreateIconFromResource((PBYTE
) &empty_anicursor3
, sizeof(empty_anicursor3
), FALSE
, 0x00030000);
1621 ok(h1
!= NULL
, "Create cursor failed (error = %d).\n", GetLastError());
1623 /* Check number of steps in multi-frame animated cursor (mismatch between steps and frames) */
1625 while (DrawIconEx(hdc
, 0, 0, h1
, 32, 32, i
, NULL
, DI_NORMAL
))
1627 ok(i
== empty_anicursor3
.header
.header
.num_steps
,
1628 "Unexpected number of steps in cursor (%d != %d)\n",
1629 i
, empty_anicursor3
.header
.header
.num_steps
);
1631 /* Check GetCursorFrameInfo behavior on rate 0 for a multi-frame animated cursor (with num_steps == 1) */
1632 rate
= steps
= 0xdead;
1633 h2
= pGetCursorFrameInfo(h1
, 0xdead, 0, &rate
, &steps
);
1634 ok(h1
!= h2
&& h2
!= 0, "GetCursorFrameInfo() failed for cursor %p: (%p, %p).\n", h1
, h1
, h2
);
1635 ret
= check_cursor_data( hdc
, h2
, &frame_identifier
[0], sizeof(DWORD
) );
1636 ok(ret
, "GetCursorFrameInfo() returned wrong cursor data for frame 0.\n");
1637 ok(rate
== empty_anicursor3
.header
.header
.display_rate
,
1638 "GetCursorFrameInfo() unexpected param 4 value (0x%x != 0x%x).\n",
1639 rate
, empty_anicursor3
.header
.header
.display_rate
);
1640 ok(steps
== ~0 || broken(steps
== empty_anicursor3
.header
.header
.num_steps
) /*win2k*/,
1641 "GetCursorFrameInfo() unexpected param 5 value (%d != ~0).\n", steps
);
1643 /* Check GetCursorFrameInfo behavior on rate 1 for a multi-frame animated cursor (with num_steps == 1) */
1644 rate
= steps
= 0xdead;
1645 h2
= pGetCursorFrameInfo(h1
, 0xdead, 1, &rate
, &steps
);
1646 ok(h2
== 0, "GetCursorFrameInfo() failed for cursor %p: (%p != 0).\n", h1
, h2
);
1647 ok(rate
== 0xdead || broken(rate
== empty_anicursor3
.header
.header
.display_rate
) /*win2k*/
1648 || broken(rate
== ~0) /*win2k (sporadic)*/,
1649 "GetCursorFrameInfo() unexpected param 4 value (0x%x != 0xdead).\n", rate
);
1650 ok(steps
== 0xdead || broken(steps
== empty_anicursor3
.header
.header
.num_steps
) /*win2k*/
1651 || broken(steps
== 0) /*win2k (sporadic)*/,
1652 "GetCursorFrameInfo() unexpected param 5 value (%d != 0xdead).\n", steps
);
1654 /* Clean up multi-frame animated cursor. */
1655 SetLastError(0xdeadbeef);
1656 ret
= DestroyCursor(h1
);
1657 ok(ret
, "DestroyCursor() failed (error = %d).\n", GetLastError());
1659 /* Creating a multi-frame animated cursor with rate data. */
1660 for (i
=0; i
<empty_anicursor3_seq
.header
.header
.num_frames
; i
++)
1662 empty_anicursor3_seq
.frames
[i
].data
.icon_info
.idType
= 2; /* type: cursor */
1663 empty_anicursor3_seq
.frames
[i
].data
.icon_info
.idEntries
[0].xHotspot
= 3;
1664 empty_anicursor3_seq
.frames
[i
].data
.icon_info
.idEntries
[0].yHotspot
= 3;
1665 memcpy( &empty_anicursor3_seq
.frames
[i
].data
.bmi_data
.data
[0], &frame_identifier
[i
], sizeof(DWORD
) );
1667 SetLastError(0xdeadbeef);
1668 h1
= CreateIconFromResource((PBYTE
) &empty_anicursor3_seq
, sizeof(empty_anicursor3_seq
), FALSE
, 0x00030000);
1669 ok(h1
!= NULL
, "Create cursor failed (error = %x).\n", GetLastError());
1671 /* Check number of steps in multi-frame animated cursor with rate data */
1673 while (DrawIconEx(hdc
, 0, 0, h1
, 32, 32, i
, NULL
, DI_NORMAL
))
1675 ok(i
== empty_anicursor3_seq
.header
.header
.num_steps
,
1676 "Unexpected number of steps in cursor (%d != %d)\n",
1677 i
, empty_anicursor3_seq
.header
.header
.num_steps
);
1679 /* Check GetCursorFrameInfo behavior on a multi-frame animated cursor with rate data */
1680 for (i
=0; i
<empty_anicursor3_seq
.header
.header
.num_frames
; i
++)
1682 int frame_id
= empty_anicursor3_seq
.seq
.order
[i
];
1684 rate
= steps
= 0xdead;
1685 h2
= pGetCursorFrameInfo(h1
, 0xdead, i
, &rate
, &steps
);
1686 ok(h1
!= h2
&& h2
!= 0, "GetCursorFrameInfo() failed for cursor %p: (%p, %p).\n", h1
, h1
, h2
);
1687 ret
= check_cursor_data( hdc
, h2
, &frame_identifier
[frame_id
], sizeof(DWORD
) );
1688 ok(ret
, "GetCursorFrameInfo() returned wrong cursor data for frame %d.\n", i
);
1689 ok(rate
== empty_anicursor3_seq
.rates
.rate
[i
],
1690 "GetCursorFrameInfo() unexpected param 4 value (0x%x != 0x%x).\n",
1691 rate
, empty_anicursor3_seq
.rates
.rate
[i
]);
1692 ok(steps
== empty_anicursor3_seq
.header
.header
.num_steps
,
1693 "GetCursorFrameInfo() unexpected param 5 value (%d != %d).\n",
1694 steps
, empty_anicursor3_seq
.header
.header
.num_steps
);
1697 /* Clean up multi-frame animated cursor with rate data. */
1698 SetLastError(0xdeadbeef);
1699 ret
= DestroyCursor(h1
);
1700 ok(ret
, "DestroyCursor() failed (error = %d).\n", GetLastError());
1703 if(bmpOld
) SelectObject(hdc
, bmpOld
);
1704 if(bmp
) DeleteObject(bmp
);
1705 if(hdc
) DeleteDC(hdc
);
1708 static HICON
create_test_icon(HDC hdc
, int width
, int height
, int bpp
,
1709 BOOL maskvalue
, UINT32
*color
, int colorSize
)
1712 BITMAPINFO bitmapInfo
;
1713 void *buffer
= NULL
;
1714 UINT32 mask
= maskvalue
? 0xFFFFFFFF : 0x00000000;
1716 memset(&bitmapInfo
, 0, sizeof(bitmapInfo
));
1717 bitmapInfo
.bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1718 bitmapInfo
.bmiHeader
.biWidth
= width
;
1719 bitmapInfo
.bmiHeader
.biHeight
= height
;
1720 bitmapInfo
.bmiHeader
.biPlanes
= 1;
1721 bitmapInfo
.bmiHeader
.biBitCount
= bpp
;
1722 bitmapInfo
.bmiHeader
.biCompression
= BI_RGB
;
1723 bitmapInfo
.bmiHeader
.biSizeImage
= colorSize
;
1725 iconInfo
.fIcon
= TRUE
;
1726 iconInfo
.xHotspot
= 0;
1727 iconInfo
.yHotspot
= 0;
1729 iconInfo
.hbmMask
= CreateBitmap( width
, height
, 1, 1, &mask
);
1730 if(!iconInfo
.hbmMask
) return NULL
;
1732 iconInfo
.hbmColor
= CreateDIBSection(hdc
, &bitmapInfo
, DIB_RGB_COLORS
, &buffer
, NULL
, 0);
1733 if(!iconInfo
.hbmColor
|| !buffer
)
1735 DeleteObject(iconInfo
.hbmMask
);
1739 memcpy(buffer
, color
, colorSize
);
1741 return CreateIconIndirect(&iconInfo
);
1744 static void check_alpha_draw(HDC hdc
, BOOL drawiconex
, BOOL alpha
, int bpp
, int line
)
1748 COLORREF modern_expected
, legacy_expected
, result
;
1750 color
[0] = 0x00A0B0C0;
1751 color
[1] = alpha
? 0xFF000000 : 0x00000000;
1752 modern_expected
= alpha
? 0x00FFFFFF : 0x00C0B0A0;
1753 legacy_expected
= 0x00C0B0A0;
1755 hicon
= create_test_icon(hdc
, 2, 1, bpp
, 0, color
, sizeof(color
));
1758 SetPixelV(hdc
, 0, 0, 0x00FFFFFF);
1761 DrawIconEx(hdc
, 0, 0, hicon
, 2, 1, 0, NULL
, DI_NORMAL
);
1763 DrawIcon(hdc
, 0, 0, hicon
);
1765 result
= GetPixel(hdc
, 0, 0);
1766 ok (color_match(result
, modern_expected
) || /* Windows 2000 and up */
1767 broken(color_match(result
, legacy_expected
)), /* Windows NT 4.0, 9X and below */
1768 "%s. Expected a close match to %06X (modern) or %06X (legacy) with %s. "
1769 "Got %06X from line %d\n",
1770 alpha
? "Alpha blending" : "Not alpha blending", modern_expected
, legacy_expected
,
1771 drawiconex
? "DrawIconEx" : "DrawIcon", result
, line
);
1774 static void check_DrawIcon(HDC hdc
, BOOL maskvalue
, UINT32 color
, int bpp
, COLORREF background
,
1775 COLORREF modern_expected
, COLORREF legacy_expected
, int line
)
1778 HICON hicon
= create_test_icon(hdc
, 1, 1, bpp
, maskvalue
, &color
, sizeof(color
));
1780 SetPixelV(hdc
, 0, 0, background
);
1781 SetPixelV(hdc
, GetSystemMetrics(SM_CXICON
)-1, GetSystemMetrics(SM_CYICON
)-1, background
);
1782 SetPixelV(hdc
, GetSystemMetrics(SM_CXICON
), GetSystemMetrics(SM_CYICON
), background
);
1783 DrawIcon(hdc
, 0, 0, hicon
);
1784 result
= GetPixel(hdc
, 0, 0);
1786 ok (color_match(result
, modern_expected
) || /* Windows 2000 and up */
1787 broken(color_match(result
, legacy_expected
)), /* Windows NT 4.0, 9X and below */
1788 "Overlaying Mask %d on Color %06X with DrawIcon. "
1789 "Expected a close match to %06X (modern), or %06X (legacy). Got %06X from line %d\n",
1790 maskvalue
, color
, modern_expected
, legacy_expected
, result
, line
);
1792 result
= GetPixel(hdc
, GetSystemMetrics(SM_CXICON
)-1, GetSystemMetrics(SM_CYICON
)-1);
1794 ok (color_match(result
, modern_expected
) || /* Windows 2000 and up */
1795 broken(color_match(result
, legacy_expected
)), /* Windows NT 4.0, 9X and below */
1796 "Overlaying Mask %d on Color %06X with DrawIcon. "
1797 "Expected a close match to %06X (modern), or %06X (legacy). Got %06X from line %d\n",
1798 maskvalue
, color
, modern_expected
, legacy_expected
, result
, line
);
1800 result
= GetPixel(hdc
, GetSystemMetrics(SM_CXICON
), GetSystemMetrics(SM_CYICON
));
1802 ok (color_match(result
, background
),
1803 "Overlaying Mask %d on Color %06X with DrawIcon. "
1804 "Expected unchanged background color %06X. Got %06X from line %d\n",
1805 maskvalue
, color
, background
, result
, line
);
1808 static void test_DrawIcon(void)
1810 BITMAPINFO bitmapInfo
;
1812 HBITMAP bmpDst
= NULL
;
1813 HBITMAP bmpOld
= NULL
;
1816 hdcDst
= CreateCompatibleDC(0);
1817 ok(hdcDst
!= 0, "CreateCompatibleDC(0) failed to return a valid DC\n");
1821 if(GetDeviceCaps(hdcDst
, BITSPIXEL
) <= 8)
1823 skip("Windows will distort DrawIcon colors at 8-bpp and less due to palettizing.\n");
1827 memset(&bitmapInfo
, 0, sizeof(bitmapInfo
));
1828 bitmapInfo
.bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1829 bitmapInfo
.bmiHeader
.biWidth
= GetSystemMetrics(SM_CXICON
)+1;
1830 bitmapInfo
.bmiHeader
.biHeight
= GetSystemMetrics(SM_CYICON
)+1;
1831 bitmapInfo
.bmiHeader
.biBitCount
= 32;
1832 bitmapInfo
.bmiHeader
.biPlanes
= 1;
1833 bitmapInfo
.bmiHeader
.biCompression
= BI_RGB
;
1834 bitmapInfo
.bmiHeader
.biSizeImage
= sizeof(UINT32
);
1836 bmpDst
= CreateDIBSection(hdcDst
, &bitmapInfo
, DIB_RGB_COLORS
, &bits
, NULL
, 0);
1837 ok (bmpDst
&& bits
, "CreateDIBSection failed to return a valid bitmap and buffer\n");
1838 if (!bmpDst
|| !bits
)
1840 bmpOld
= SelectObject(hdcDst
, bmpDst
);
1842 /* Mask is only heeded if alpha channel is always zero */
1843 check_DrawIcon(hdcDst
, FALSE
, 0x00A0B0C0, 32, 0x00FFFFFF, 0x00C0B0A0, 0x00C0B0A0, __LINE__
);
1844 check_DrawIcon(hdcDst
, TRUE
, 0x00A0B0C0, 32, 0x00FFFFFF, 0x003F4F5F, 0x003F4F5F, __LINE__
);
1846 /* Test alpha blending */
1847 /* Windows 2000 and up will alpha blend, earlier Windows versions will not */
1848 check_DrawIcon(hdcDst
, FALSE
, 0xFFA0B0C0, 32, 0x00FFFFFF, 0x00C0B0A0, 0x00C0B0A0, __LINE__
);
1849 check_DrawIcon(hdcDst
, TRUE
, 0xFFA0B0C0, 32, 0x00FFFFFF, 0x00C0B0A0, 0x003F4F5F, __LINE__
);
1851 check_DrawIcon(hdcDst
, FALSE
, 0x80A0B0C0, 32, 0x00000000, 0x00605850, 0x00C0B0A0, __LINE__
);
1852 check_DrawIcon(hdcDst
, TRUE
, 0x80A0B0C0, 32, 0x00000000, 0x00605850, 0x00C0B0A0, __LINE__
);
1853 check_DrawIcon(hdcDst
, FALSE
, 0x80A0B0C0, 32, 0x00FFFFFF, 0x00DFD7CF, 0x00C0B0A0, __LINE__
);
1854 check_DrawIcon(hdcDst
, TRUE
, 0x80A0B0C0, 32, 0x00FFFFFF, 0x00DFD7CF, 0x003F4F5F, __LINE__
);
1856 check_DrawIcon(hdcDst
, FALSE
, 0x01FFFFFF, 32, 0x00000000, 0x00010101, 0x00FFFFFF, __LINE__
);
1857 check_DrawIcon(hdcDst
, TRUE
, 0x01FFFFFF, 32, 0x00000000, 0x00010101, 0x00FFFFFF, __LINE__
);
1859 /* Test detecting of alpha channel */
1860 /* If a single pixel's alpha channel is non-zero, the icon
1861 will be alpha blended, otherwise it will be draw with
1863 check_alpha_draw(hdcDst
, FALSE
, FALSE
, 32, __LINE__
);
1864 check_alpha_draw(hdcDst
, FALSE
, TRUE
, 32, __LINE__
);
1868 SelectObject(hdcDst
, bmpOld
);
1870 DeleteObject(bmpDst
);
1875 static void check_DrawIconEx(HDC hdc
, BOOL maskvalue
, UINT32 color
, int bpp
, UINT flags
, COLORREF background
,
1876 COLORREF modern_expected
, COLORREF legacy_expected
, int line
)
1879 HICON hicon
= create_test_icon(hdc
, 1, 1, bpp
, maskvalue
, &color
, sizeof(color
));
1881 SetPixelV(hdc
, 0, 0, background
);
1882 DrawIconEx(hdc
, 0, 0, hicon
, 1, 1, 0, NULL
, flags
);
1883 result
= GetPixel(hdc
, 0, 0);
1885 ok (color_match(result
, modern_expected
) || /* Windows 2000 and up */
1886 broken(color_match(result
, legacy_expected
)), /* Windows NT 4.0, 9X and below */
1887 "Overlaying Mask %d on Color %06X with DrawIconEx flags %08X. "
1888 "Expected a close match to %06X (modern) or %06X (legacy). Got %06X from line %d\n",
1889 maskvalue
, color
, flags
, modern_expected
, legacy_expected
, result
, line
);
1892 static void test_DrawIconEx(void)
1894 BITMAPINFO bitmapInfo
;
1896 HBITMAP bmpDst
= NULL
;
1897 HBITMAP bmpOld
= NULL
;
1900 hdcDst
= CreateCompatibleDC(0);
1901 ok(hdcDst
!= 0, "CreateCompatibleDC(0) failed to return a valid DC\n");
1905 if(GetDeviceCaps(hdcDst
, BITSPIXEL
) <= 8)
1907 skip("Windows will distort DrawIconEx colors at 8-bpp and less due to palettizing.\n");
1911 memset(&bitmapInfo
, 0, sizeof(bitmapInfo
));
1912 bitmapInfo
.bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1913 bitmapInfo
.bmiHeader
.biWidth
= 1;
1914 bitmapInfo
.bmiHeader
.biHeight
= 1;
1915 bitmapInfo
.bmiHeader
.biBitCount
= 32;
1916 bitmapInfo
.bmiHeader
.biPlanes
= 1;
1917 bitmapInfo
.bmiHeader
.biCompression
= BI_RGB
;
1918 bitmapInfo
.bmiHeader
.biSizeImage
= sizeof(UINT32
);
1919 bmpDst
= CreateDIBSection(hdcDst
, &bitmapInfo
, DIB_RGB_COLORS
, &bits
, NULL
, 0);
1920 ok (bmpDst
&& bits
, "CreateDIBSection failed to return a valid bitmap and buffer\n");
1921 if (!bmpDst
|| !bits
)
1923 bmpOld
= SelectObject(hdcDst
, bmpDst
);
1925 /* Test null, image only, and mask only drawing */
1926 check_DrawIconEx(hdcDst
, FALSE
, 0x00A0B0C0, 32, 0, 0x00102030, 0x00102030, 0x00102030, __LINE__
);
1927 check_DrawIconEx(hdcDst
, TRUE
, 0x00A0B0C0, 32, 0, 0x00102030, 0x00102030, 0x00102030, __LINE__
);
1929 check_DrawIconEx(hdcDst
, FALSE
, 0x80A0B0C0, 32, DI_MASK
, 0x00123456, 0x00000000, 0x00000000, __LINE__
);
1930 check_DrawIconEx(hdcDst
, TRUE
, 0x80A0B0C0, 32, DI_MASK
, 0x00123456, 0x00FFFFFF, 0x00FFFFFF, __LINE__
);
1932 check_DrawIconEx(hdcDst
, FALSE
, 0x00A0B0C0, 32, DI_IMAGE
, 0x00FFFFFF, 0x00C0B0A0, 0x00C0B0A0, __LINE__
);
1933 check_DrawIconEx(hdcDst
, TRUE
, 0x00A0B0C0, 32, DI_IMAGE
, 0x00FFFFFF, 0x00C0B0A0, 0x00C0B0A0, __LINE__
);
1935 /* Test normal drawing */
1936 check_DrawIconEx(hdcDst
, FALSE
, 0x00A0B0C0, 32, DI_NORMAL
, 0x00FFFFFF, 0x00C0B0A0, 0x00C0B0A0, __LINE__
);
1937 check_DrawIconEx(hdcDst
, TRUE
, 0x00A0B0C0, 32, DI_NORMAL
, 0x00FFFFFF, 0x003F4F5F, 0x003F4F5F, __LINE__
);
1938 check_DrawIconEx(hdcDst
, FALSE
, 0xFFA0B0C0, 32, DI_NORMAL
, 0x00FFFFFF, 0x00C0B0A0, 0x00C0B0A0, __LINE__
);
1940 /* Test alpha blending */
1941 /* Windows 2000 and up will alpha blend, earlier Windows versions will not */
1942 check_DrawIconEx(hdcDst
, TRUE
, 0xFFA0B0C0, 32, DI_NORMAL
, 0x00FFFFFF, 0x00C0B0A0, 0x003F4F5F, __LINE__
);
1944 check_DrawIconEx(hdcDst
, FALSE
, 0x80A0B0C0, 32, DI_NORMAL
, 0x00000000, 0x00605850, 0x00C0B0A0, __LINE__
);
1945 check_DrawIconEx(hdcDst
, TRUE
, 0x80A0B0C0, 32, DI_NORMAL
, 0x00000000, 0x00605850, 0x00C0B0A0, __LINE__
);
1946 check_DrawIconEx(hdcDst
, FALSE
, 0x80A0B0C0, 32, DI_NORMAL
, 0x00FFFFFF, 0x00DFD7CF, 0x00C0B0A0, __LINE__
);
1947 check_DrawIconEx(hdcDst
, TRUE
, 0x80A0B0C0, 32, DI_NORMAL
, 0x00FFFFFF, 0x00DFD7CF, 0x003F4F5F, __LINE__
);
1949 check_DrawIconEx(hdcDst
, FALSE
, 0x01FFFFFF, 32, DI_NORMAL
, 0x00000000, 0x00010101, 0x00FFFFFF, __LINE__
);
1950 check_DrawIconEx(hdcDst
, TRUE
, 0x01FFFFFF, 32, DI_NORMAL
, 0x00000000, 0x00010101, 0x00FFFFFF, __LINE__
);
1952 /* Test detecting of alpha channel */
1953 /* If a single pixel's alpha channel is non-zero, the icon
1954 will be alpha blended, otherwise it will be draw with
1956 check_alpha_draw(hdcDst
, TRUE
, FALSE
, 32, __LINE__
);
1957 check_alpha_draw(hdcDst
, TRUE
, TRUE
, 32, __LINE__
);
1961 SelectObject(hdcDst
, bmpOld
);
1963 DeleteObject(bmpDst
);
1968 static void check_DrawState_Size(HDC hdc
, BOOL maskvalue
, UINT32 color
, int bpp
, HBRUSH hbr
, UINT flags
, int line
)
1970 COLORREF result
, background
;
1972 HICON hicon
= create_test_icon(hdc
, 1, 1, bpp
, maskvalue
, &color
, sizeof(color
));
1973 background
= 0x00FFFFFF;
1974 /* Set color of the 2 pixels that will be checked afterwards */
1975 SetPixelV(hdc
, 0, 0, background
);
1976 SetPixelV(hdc
, 2, 2, background
);
1978 /* Let DrawState calculate the size of the icon (it's 1x1) */
1979 DrawState(hdc
, hbr
, NULL
, (LPARAM
) hicon
, 0, 1, 1, 0, 0, (DST_ICON
| flags
));
1981 result
= GetPixel(hdc
, 0, 0);
1982 passed
[0] = color_match(result
, background
);
1983 result
= GetPixel(hdc
, 2, 2);
1984 passed
[0] = passed
[0] & color_match(result
, background
);
1986 /* Check if manually specifying the icon size DOESN'T work */
1988 /* IMPORTANT: For Icons, DrawState wants the size of the source image, not the
1989 * size in which it should be ultimately drawn. Therefore giving
1990 * width/height 2x2 if the icon is only 1x1 pixels in size should
1991 * result in drawing it with size 1x1. The size parameters must be
1992 * ignored if a Icon has to be drawn! */
1993 DrawState(hdc
, hbr
, NULL
, (LPARAM
) hicon
, 0, 1, 1, 2, 2, (DST_ICON
| flags
));
1995 result
= GetPixel(hdc
, 0, 0);
1996 passed
[1] = color_match(result
, background
);
1997 result
= GetPixel(hdc
, 2, 2);
1998 passed
[1] = passed
[0] & color_match(result
, background
);
2000 if(!passed
[0]&&!passed
[1])
2002 "DrawState failed to draw a 1x1 Icon in the correct size, independent of the "
2003 "width and height settings passed to it, for Icon with: Overlaying Mask %d on "
2004 "Color %06X with flags %08X. Line %d\n",
2005 maskvalue
, color
, (DST_ICON
| flags
), line
);
2008 "DrawState failed to draw a 1x1 Icon in the correct size, if the width and height "
2009 "parameters passed to it are bigger than the real Icon size, for Icon with: Overlaying "
2010 "Mask %d on Color %06X with flags %08X. Line %d\n",
2011 maskvalue
, color
, (DST_ICON
| flags
), line
);
2014 "DrawState failed to draw a 1x1 Icon in the correct size, if the width and height "
2015 "parameters passed to it are 0, for Icon with: Overlaying Mask %d on "
2016 "Color %06X with flags %08X. Line %d\n",
2017 maskvalue
, color
, (DST_ICON
| flags
), line
);
2020 static void check_DrawState_Color(HDC hdc
, BOOL maskvalue
, UINT32 color
, int bpp
, HBRUSH hbr
, UINT flags
,
2021 COLORREF background
, COLORREF modern_expected
, COLORREF legacy_expected
, int line
)
2024 HICON hicon
= create_test_icon(hdc
, 1, 1, bpp
, maskvalue
, &color
, sizeof(color
));
2026 /* Set color of the pixel that will be checked afterwards */
2027 SetPixelV(hdc
, 1, 1, background
);
2029 DrawState(hdc
, hbr
, NULL
, (LPARAM
) hicon
, 0, 1, 1, 0, 0, ( DST_ICON
| flags
));
2031 /* Check the color of the pixel is correct */
2032 result
= GetPixel(hdc
, 1, 1);
2034 ok (color_match(result
, modern_expected
) || /* Windows 2000 and up */
2035 broken(color_match(result
, legacy_expected
)), /* Windows NT 4.0, 9X and below */
2036 "DrawState drawing Icon with Overlaying Mask %d on Color %06X with flags %08X. "
2037 "Expected a close match to %06X (modern) or %06X (legacy). Got %06X from line %d\n",
2038 maskvalue
, color
, (DST_ICON
| flags
), modern_expected
, legacy_expected
, result
, line
);
2041 static void test_DrawState(void)
2043 BITMAPINFO bitmapInfo
;
2045 HBITMAP bmpDst
= NULL
;
2046 HBITMAP bmpOld
= NULL
;
2049 hdcDst
= CreateCompatibleDC(0);
2050 ok(hdcDst
!= 0, "CreateCompatibleDC(0) failed to return a valid DC\n");
2054 if(GetDeviceCaps(hdcDst
, BITSPIXEL
) <= 8)
2056 skip("Windows will distort DrawIconEx colors at 8-bpp and less due to palettizing.\n");
2060 memset(&bitmapInfo
, 0, sizeof(bitmapInfo
));
2061 bitmapInfo
.bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
2062 bitmapInfo
.bmiHeader
.biWidth
= 3;
2063 bitmapInfo
.bmiHeader
.biHeight
= 3;
2064 bitmapInfo
.bmiHeader
.biBitCount
= 32;
2065 bitmapInfo
.bmiHeader
.biPlanes
= 1;
2066 bitmapInfo
.bmiHeader
.biCompression
= BI_RGB
;
2067 bitmapInfo
.bmiHeader
.biSizeImage
= sizeof(UINT32
);
2068 bmpDst
= CreateDIBSection(hdcDst
, &bitmapInfo
, DIB_RGB_COLORS
, &bits
, NULL
, 0);
2069 ok (bmpDst
&& bits
, "CreateDIBSection failed to return a valid bitmap and buffer\n");
2070 if (!bmpDst
|| !bits
)
2072 bmpOld
= SelectObject(hdcDst
, bmpDst
);
2074 /* potential flags to test with DrawState are: */
2075 /* DSS_DISABLED embosses the icon */
2076 /* DSS_MONO draw Icon using a brush as parameter 5 */
2077 /* DSS_NORMAL draw Icon without any modifications */
2078 /* DSS_UNION draw the Icon dithered */
2080 check_DrawState_Size(hdcDst
, FALSE
, 0x00A0B0C0, 32, 0, DSS_NORMAL
, __LINE__
);
2081 check_DrawState_Color(hdcDst
, FALSE
, 0x00A0B0C0, 32, 0, DSS_NORMAL
, 0x00FFFFFF, 0x00C0B0A0, 0x00C0B0A0, __LINE__
);
2085 SelectObject(hdcDst
, bmpOld
);
2087 DeleteObject(bmpDst
);
2092 static DWORD parent_id
;
2094 static DWORD CALLBACK
set_cursor_thread( void *arg
)
2098 PeekMessage( 0, 0, 0, 0, PM_NOREMOVE
); /* create a msg queue */
2101 BOOL ret
= AttachThreadInput( GetCurrentThreadId(), parent_id
, TRUE
);
2102 ok( ret
, "AttachThreadInput failed\n" );
2104 if (arg
) ret
= SetCursor( (HCURSOR
)arg
);
2105 else ret
= GetCursor();
2106 return (DWORD_PTR
)ret
;
2109 static void test_SetCursor(void)
2111 static const BYTE bmp_bits
[4096];
2112 ICONINFO cursorInfo
;
2113 HCURSOR cursor
, old_cursor
, global_cursor
= 0;
2114 DWORD error
, id
, result
;
2122 memset( &info
, 0, sizeof(info
) );
2123 info
.cbSize
= sizeof(info
);
2124 if (!pGetCursorInfo( &info
))
2126 win_skip( "GetCursorInfo not working\n" );
2127 pGetCursorInfo
= NULL
;
2129 else global_cursor
= info
.hCursor
;
2131 cursor
= GetCursor();
2132 thread
= CreateThread( NULL
, 0, set_cursor_thread
, 0, 0, &id
);
2133 WaitForSingleObject( thread
, 1000 );
2134 GetExitCodeThread( thread
, &result
);
2135 ok( result
== (DWORD_PTR
)cursor
, "wrong thread cursor %x/%p\n", result
, cursor
);
2138 display_bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
2141 cursorInfo
.fIcon
= FALSE
;
2142 cursorInfo
.xHotspot
= 0;
2143 cursorInfo
.yHotspot
= 0;
2144 cursorInfo
.hbmMask
= CreateBitmap(32, 32, 1, 1, bmp_bits
);
2145 cursorInfo
.hbmColor
= CreateBitmap(32, 32, 1, display_bpp
, bmp_bits
);
2147 cursor
= CreateIconIndirect(&cursorInfo
);
2148 ok(cursor
!= NULL
, "CreateIconIndirect returned %p\n", cursor
);
2149 old_cursor
= SetCursor( cursor
);
2153 info
.cbSize
= sizeof(info
);
2154 ok( pGetCursorInfo( &info
), "GetCursorInfo failed\n" );
2155 /* global cursor doesn't change since we don't have a window */
2156 ok( info
.hCursor
== global_cursor
|| broken(info
.hCursor
!= cursor
), /* win9x */
2157 "wrong info cursor %p/%p\n", info
.hCursor
, global_cursor
);
2159 thread
= CreateThread( NULL
, 0, set_cursor_thread
, 0, 0, &id
);
2160 WaitForSingleObject( thread
, 1000 );
2161 GetExitCodeThread( thread
, &result
);
2162 ok( result
== (DWORD_PTR
)old_cursor
, "wrong thread cursor %x/%p\n", result
, old_cursor
);
2165 ok( GetCursor() == 0, "wrong cursor %p\n", GetCursor() );
2166 thread
= CreateThread( NULL
, 0, set_cursor_thread
, 0, 0, &id
);
2167 WaitForSingleObject( thread
, 1000 );
2168 GetExitCodeThread( thread
, &result
);
2169 ok( result
== (DWORD_PTR
)old_cursor
, "wrong thread cursor %x/%p\n", result
, old_cursor
);
2171 thread
= CreateThread( NULL
, 0, set_cursor_thread
, cursor
, 0, &id
);
2172 WaitForSingleObject( thread
, 1000 );
2173 GetExitCodeThread( thread
, &result
);
2174 ok( result
== (DWORD_PTR
)old_cursor
, "wrong thread cursor %x/%p\n", result
, old_cursor
);
2175 ok( GetCursor() == 0, "wrong cursor %p/0\n", GetCursor() );
2177 parent_id
= GetCurrentThreadId();
2178 thread
= CreateThread( NULL
, 0, set_cursor_thread
, cursor
, 0, &id
);
2179 WaitForSingleObject( thread
, 1000 );
2180 GetExitCodeThread( thread
, &result
);
2181 ok( result
== (DWORD_PTR
)old_cursor
, "wrong thread cursor %x/%p\n", result
, old_cursor
);
2182 ok( GetCursor() == cursor
, "wrong cursor %p/0\n", cursor
);
2186 info
.cbSize
= sizeof(info
);
2187 ok( pGetCursorInfo( &info
), "GetCursorInfo failed\n" );
2188 ok( info
.hCursor
== global_cursor
|| broken(info
.hCursor
!= cursor
), /* win9x */
2189 "wrong info cursor %p/%p\n", info
.hCursor
, global_cursor
);
2191 SetCursor( old_cursor
);
2192 DestroyCursor( cursor
);
2194 SetLastError( 0xdeadbeef );
2195 cursor
= SetCursor( (HCURSOR
)0xbadbad );
2196 error
= GetLastError();
2197 ok( cursor
== 0, "wrong cursor %p/0\n", cursor
);
2198 ok( error
== ERROR_INVALID_CURSOR_HANDLE
|| broken( error
== 0xdeadbeef ), /* win9x */
2199 "wrong error %u\n", error
);
2203 info
.cbSize
= sizeof(info
);
2204 ok( pGetCursorInfo( &info
), "GetCursorInfo failed\n" );
2205 ok( info
.hCursor
== global_cursor
|| broken(info
.hCursor
!= cursor
), /* win9x */
2206 "wrong info cursor %p/%p\n", info
.hCursor
, global_cursor
);
2210 static HANDLE event_start
, event_next
;
2212 static DWORD CALLBACK
show_cursor_thread( void *arg
)
2214 DWORD count
= (DWORD_PTR
)arg
;
2217 PeekMessage( 0, 0, 0, 0, PM_NOREMOVE
); /* create a msg queue */
2220 BOOL ret
= AttachThreadInput( GetCurrentThreadId(), parent_id
, TRUE
);
2221 ok( ret
, "AttachThreadInput failed\n" );
2223 if (!count
) ret
= ShowCursor( FALSE
);
2224 else while (count
--) ret
= ShowCursor( TRUE
);
2225 SetEvent( event_start
);
2226 WaitForSingleObject( event_next
, 2000 );
2230 static void test_ShowCursor(void)
2239 memset( &info
, 0, sizeof(info
) );
2240 info
.cbSize
= sizeof(info
);
2241 ok( pGetCursorInfo( &info
), "GetCursorInfo failed\n" );
2242 ok( info
.flags
& CURSOR_SHOWING
, "cursor not shown in info\n" );
2245 event_start
= CreateEvent( NULL
, FALSE
, FALSE
, NULL
);
2246 event_next
= CreateEvent( NULL
, FALSE
, FALSE
, NULL
);
2248 count
= ShowCursor( TRUE
);
2249 ok( count
== 1, "wrong count %d\n", count
);
2250 count
= ShowCursor( TRUE
);
2251 ok( count
== 2, "wrong count %d\n", count
);
2252 count
= ShowCursor( FALSE
);
2253 ok( count
== 1, "wrong count %d\n", count
);
2254 count
= ShowCursor( FALSE
);
2255 ok( count
== 0, "wrong count %d\n", count
);
2256 count
= ShowCursor( FALSE
);
2257 ok( count
== -1, "wrong count %d\n", count
);
2258 count
= ShowCursor( FALSE
);
2259 ok( count
== -2, "wrong count %d\n", count
);
2263 info
.cbSize
= sizeof(info
);
2264 ok( pGetCursorInfo( &info
), "GetCursorInfo failed\n" );
2265 /* global show count is not affected since we don't have a window */
2266 ok( info
.flags
& CURSOR_SHOWING
, "cursor not shown in info\n" );
2270 thread
= CreateThread( NULL
, 0, show_cursor_thread
, NULL
, 0, &id
);
2271 WaitForSingleObject( event_start
, 1000 );
2272 count
= ShowCursor( FALSE
);
2273 ok( count
== -3, "wrong count %d\n", count
);
2274 SetEvent( event_next
);
2275 WaitForSingleObject( thread
, 1000 );
2276 GetExitCodeThread( thread
, &result
);
2277 ok( result
== -1, "wrong thread count %d\n", result
);
2278 count
= ShowCursor( FALSE
);
2279 ok( count
== -4, "wrong count %d\n", count
);
2281 thread
= CreateThread( NULL
, 0, show_cursor_thread
, (void *)1, 0, &id
);
2282 WaitForSingleObject( event_start
, 1000 );
2283 count
= ShowCursor( TRUE
);
2284 ok( count
== -3, "wrong count %d\n", count
);
2285 SetEvent( event_next
);
2286 WaitForSingleObject( thread
, 1000 );
2287 GetExitCodeThread( thread
, &result
);
2288 ok( result
== 1, "wrong thread count %d\n", result
);
2289 count
= ShowCursor( TRUE
);
2290 ok( count
== -2, "wrong count %d\n", count
);
2292 parent_id
= GetCurrentThreadId();
2293 thread
= CreateThread( NULL
, 0, show_cursor_thread
, NULL
, 0, &id
);
2294 WaitForSingleObject( event_start
, 1000 );
2295 count
= ShowCursor( TRUE
);
2296 ok( count
== -2, "wrong count %d\n", count
);
2297 SetEvent( event_next
);
2298 WaitForSingleObject( thread
, 1000 );
2299 GetExitCodeThread( thread
, &result
);
2300 ok( result
== -3, "wrong thread count %d\n", result
);
2301 count
= ShowCursor( FALSE
);
2302 ok( count
== -2, "wrong count %d\n", count
);
2304 thread
= CreateThread( NULL
, 0, show_cursor_thread
, (void *)3, 0, &id
);
2305 WaitForSingleObject( event_start
, 1000 );
2306 count
= ShowCursor( TRUE
);
2307 ok( count
== 2, "wrong count %d\n", count
);
2308 SetEvent( event_next
);
2309 WaitForSingleObject( thread
, 1000 );
2310 GetExitCodeThread( thread
, &result
);
2311 ok( result
== 1, "wrong thread count %d\n", result
);
2312 count
= ShowCursor( FALSE
);
2313 ok( count
== -2, "wrong count %d\n", count
);
2317 info
.cbSize
= sizeof(info
);
2318 ok( pGetCursorInfo( &info
), "GetCursorInfo failed\n" );
2319 ok( info
.flags
& CURSOR_SHOWING
, "cursor not shown in info\n" );
2322 count
= ShowCursor( TRUE
);
2323 ok( count
== -1, "wrong count %d\n", count
);
2324 count
= ShowCursor( TRUE
);
2325 ok( count
== 0, "wrong count %d\n", count
);
2329 info
.cbSize
= sizeof(info
);
2330 ok( pGetCursorInfo( &info
), "GetCursorInfo failed\n" );
2331 ok( info
.flags
& CURSOR_SHOWING
, "cursor not shown in info\n" );
2336 static void test_DestroyCursor(void)
2338 static const BYTE bmp_bits
[4096];
2339 ICONINFO cursorInfo
, new_info
;
2340 HCURSOR cursor
, cursor2
, new_cursor
;
2347 display_bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
2350 cursorInfo
.fIcon
= FALSE
;
2351 cursorInfo
.xHotspot
= 0;
2352 cursorInfo
.yHotspot
= 0;
2353 cursorInfo
.hbmMask
= CreateBitmap(32, 32, 1, 1, bmp_bits
);
2354 cursorInfo
.hbmColor
= CreateBitmap(32, 32, 1, display_bpp
, bmp_bits
);
2356 cursor
= CreateIconIndirect(&cursorInfo
);
2357 ok(cursor
!= NULL
, "CreateIconIndirect returned %p\n", cursor
);
2363 SetLastError(0xdeadbeef);
2364 ret
= DestroyCursor(cursor
);
2365 ok(!ret
|| broken(ret
) /* succeeds on win9x */, "DestroyCursor on the active cursor succeeded\n");
2366 error
= GetLastError();
2367 ok(error
== 0xdeadbeef, "Last error: %u\n", error
);
2369 new_cursor
= GetCursor();
2370 if (ret
) /* win9x replaces cursor by another one on destroy */
2371 ok(new_cursor
!= cursor
, "GetCursor returned %p/%p\n", new_cursor
, cursor
);
2373 ok(new_cursor
== cursor
, "GetCursor returned %p/%p\n", new_cursor
, cursor
);
2375 SetLastError(0xdeadbeef);
2376 ret
= GetIconInfo( cursor
, &new_info
);
2377 ok( !ret
|| broken(ret
), /* nt4 */ "GetIconInfo succeeded\n" );
2378 ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE
||
2379 broken(GetLastError() == 0xdeadbeef), /* win9x */
2380 "wrong error %u\n", GetLastError() );
2382 if (ret
) /* nt4 delays destruction until cursor changes */
2384 DeleteObject( new_info
.hbmColor
);
2385 DeleteObject( new_info
.hbmMask
);
2387 SetLastError(0xdeadbeef);
2388 ret
= DestroyCursor( cursor
);
2389 ok( !ret
, "DestroyCursor succeeded\n" );
2390 ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE
|| GetLastError() == 0xdeadbeef,
2391 "wrong error %u\n", GetLastError() );
2393 SetLastError(0xdeadbeef);
2394 cursor2
= SetCursor( cursor
);
2395 ok( cursor2
== cursor
, "SetCursor returned %p/%p\n", cursor2
, cursor
);
2396 ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE
|| GetLastError() == 0xdeadbeef,
2397 "wrong error %u\n", GetLastError() );
2401 SetLastError(0xdeadbeef);
2402 cursor2
= CopyCursor( cursor
);
2403 ok(!cursor2
, "CopyCursor succeeded\n" );
2404 ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE
||
2405 broken(GetLastError() == 0xdeadbeef), /* win9x */
2406 "wrong error %u\n", GetLastError() );
2408 SetLastError(0xdeadbeef);
2409 ret
= DestroyCursor( cursor
);
2410 if (new_cursor
!= cursor
) /* win9x */
2411 ok( ret
, "DestroyCursor succeeded\n" );
2413 ok( !ret
, "DestroyCursor succeeded\n" );
2414 ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE
|| GetLastError() == 0xdeadbeef,
2415 "wrong error %u\n", GetLastError() );
2417 SetLastError(0xdeadbeef);
2418 cursor2
= SetCursor( cursor
);
2419 ok(!cursor2
, "SetCursor returned %p/%p\n", cursor2
, cursor
);
2420 ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE
|| GetLastError() == 0xdeadbeef,
2421 "wrong error %u\n", GetLastError() );
2424 cursor2
= GetCursor();
2425 ok(cursor2
== new_cursor
, "GetCursor returned %p/%p\n", cursor2
, new_cursor
);
2427 SetLastError(0xdeadbeef);
2428 cursor2
= SetCursor( 0 );
2429 if (new_cursor
!= cursor
) /* win9x */
2430 ok(cursor2
== new_cursor
, "SetCursor returned %p/%p\n", cursor2
, cursor
);
2432 ok(!cursor2
, "SetCursor returned %p/%p\n", cursor2
, cursor
);
2433 ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
2435 cursor2
= GetCursor();
2436 ok(!cursor2
, "GetCursor returned %p/%p\n", cursor2
, cursor
);
2438 SetLastError(0xdeadbeef);
2439 ret
= DestroyCursor(cursor
);
2440 if (new_cursor
!= cursor
) /* win9x */
2441 ok( ret
, "DestroyCursor succeeded\n" );
2443 ok( !ret
, "DestroyCursor succeeded\n" );
2444 ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE
|| GetLastError() == 0xdeadbeef,
2445 "wrong error %u\n", GetLastError() );
2447 DeleteObject(cursorInfo
.hbmMask
);
2448 DeleteObject(cursorInfo
.hbmColor
);
2450 /* Try testing DestroyCursor() now using LoadCursor() cursors. */
2451 cursor
= LoadCursor(NULL
, IDC_ARROW
);
2453 SetLastError(0xdeadbeef);
2454 ret
= DestroyCursor(cursor
);
2455 ok(ret
|| broken(!ret
) /* fails on win9x */, "DestroyCursor on the active cursor failed.\n");
2456 error
= GetLastError();
2457 ok(error
== 0xdeadbeef, "Last error: 0x%08x\n", error
);
2459 /* Try setting the cursor to a destroyed OEM cursor. */
2460 SetLastError(0xdeadbeef);
2462 error
= GetLastError();
2463 ok(error
== 0xdeadbeef, "Last error: 0x%08x\n", error
);
2465 /* Check if LoadCursor() returns the same handle with the same icon. */
2466 cursor2
= LoadCursor(NULL
, IDC_ARROW
);
2467 ok(cursor2
== cursor
, "cursor == %p, cursor2 == %p\n", cursor
, cursor2
);
2469 /* Check if LoadCursor() returns the same handle with a different icon. */
2470 cursor2
= LoadCursor(NULL
, IDC_WAIT
);
2471 ok(cursor2
!= cursor
, "cursor == %p, cursor2 == %p\n", cursor
, cursor2
);
2474 START_TEST(cursoricon
)
2476 pGetCursorInfo
= (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetCursorInfo" );
2477 pGetIconInfoExA
= (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetIconInfoExA" );
2478 pGetIconInfoExW
= (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetIconInfoExW" );
2479 pGetCursorFrameInfo
= (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetCursorFrameInfo" );
2480 test_argc
= winetest_get_mainargs(&test_argv
);
2484 /* Child process. */
2485 sscanf (test_argv
[2], "%x", (unsigned int *) &parent
);
2487 ok(parent
!= NULL
, "Parent not found.\n");
2495 test_CopyImage_Bitmap(1);
2496 test_CopyImage_Bitmap(4);
2497 test_CopyImage_Bitmap(8);
2498 test_CopyImage_Bitmap(16);
2499 test_CopyImage_Bitmap(24);
2500 test_CopyImage_Bitmap(32);
2501 test_initial_cursor();
2504 test_CreateIconFromResource();
2505 test_GetCursorFrameInfo();
2511 test_DestroyCursor();
2513 test_child_process();
2514 finish_child_process();