7 START_TEST(CreateIconFromResourceEx
)
11 HRSRC hResource
; // handle to FindResource
12 HRSRC hMem
; // handle to LoadResource
13 BYTE
*lpResource
; // pointer to resource data
17 hMod
= GetModuleHandle(NULL
);
18 ok(hMod
!= NULL
, "\n");
19 /* Create a shared cursor */
20 hcur1
= LoadCursor(hMod
, "TESTCURSOR");
21 ok(hcur1
!= NULL
, "\n");
23 /* Create it manually using CreateIconFromResourceEx */
24 hResource
= FindResourceA(hMod
,
27 ok(hResource
!= NULL
, "\n");
29 hMem
= LoadResource(hMod
, hResource
);
30 ok(hMem
!= NULL
, "\n");
32 lpResource
= LockResource(hMem
);
33 ok(lpResource
!= NULL
, "\n");
35 /* MSDN states that LR_SHARED permits to not load twice the same cursor again.
36 * But CreateIconFromResourceEx still returns two different handles */
37 hcur2
= CreateIconFromResourceEx(lpResource
, SizeofResource(hMod
, hResource
), FALSE
, 0x00030000, 0, 0, LR_SHARED
);
38 ok(hcur2
!= NULL
, "\n");
39 ok(hcur2
!= hcur1
, "\n");
40 hcur1
= CreateIconFromResourceEx(lpResource
, SizeofResource(hMod
, hResource
), FALSE
, 0x00030000, 0, 0, LR_SHARED
);
41 ok(hcur1
!= NULL
, "\n");
42 ok(hcur2
!= hcur1
, "\n");
44 /* Try to destroy them multiple times (see DestroyCursor test) */
45 ok(DestroyCursor(hcur1
), "\n");
46 ok(DestroyCursor(hcur1
), "\n");
47 ok(DestroyCursor(hcur2
), "\n");
48 ok(DestroyCursor(hcur2
), "\n");
50 /* See what happens if we ask for an icon on a cursor resource (directory) */
51 SetLastError(0x0badf00d);
52 hcur1
= CreateIconFromResourceEx(lpResource
, SizeofResource(hMod
, hResource
), TRUE
, 0x00030000, 0, 0, 0);
53 ok(hcur1
== NULL
, "\n");
55 ok(err
== 0x0badf00d, "err: %lu\n", err
);
57 /* Same tests, but for cursor resource (not directory) */
58 wResId
= LookupIconIdFromDirectoryEx(lpResource
, FALSE
, 0, 0, 0);
59 ok(wResId
!= 0, "\n");
60 FreeResource(hResource
);
62 hResource
= FindResourceA(hMod
, MAKEINTRESOURCEA(wResId
), RT_CURSOR
);
63 ok(hResource
!= NULL
, "\n");
65 hMem
= LoadResource(hMod
, hResource
);
66 ok(hMem
!= NULL
, "\n");
68 lpResource
= LockResource(hMem
);
69 ok(lpResource
!= NULL
, "\n");
71 /* MSDN states that LR_SHARED permits to not load twice the same cursor again.
72 * But CreateIconFromResourceEx still returns two different handles */
73 hcur2
= CreateIconFromResourceEx(lpResource
, SizeofResource(hMod
, hResource
), FALSE
, 0x00030000, 0, 0, LR_SHARED
);
74 ok(hcur2
!= NULL
, "\n");
75 ok(hcur2
!= hcur1
, "\n");
76 hcur1
= CreateIconFromResourceEx(lpResource
, SizeofResource(hMod
, hResource
), FALSE
, 0x00030000, 0, 0, LR_SHARED
);
77 ok(hcur1
!= NULL
, "\n");
78 ok(hcur2
!= hcur1
, "\n");
80 /* Try to destroy them multiple times (see DestroyCursor test) */
81 ok(DestroyCursor(hcur1
), "\n");
82 ok(DestroyCursor(hcur1
), "\n");
83 ok(DestroyCursor(hcur2
), "\n");
84 ok(DestroyCursor(hcur2
), "\n");
86 /* See what happens if we ask for an icon on a cursor resource (no directory) */
87 SetLastError(0x0badf00d);
88 hcur1
= CreateIconFromResourceEx(lpResource
, SizeofResource(hMod
, hResource
), TRUE
, 0x00030000, 0, 0, 0);
89 ok(hcur1
== NULL
, "\n");
91 ok(err
== 0x0badf00d, "err: %lu\n", err
);