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