ReactOS 0.4.15-dev-7842-g558ab78
CreateIconIndirect.c
Go to the documentation of this file.
1
2#include "precomp.h"
3
4// FIXME user32
5
6void
8{
9 HICON hicon;
10 ICONINFO iconinfo, iconinfo2;
12
13 iconinfo.fIcon = fIcon;
14 iconinfo.xHotspot = 0;
15 iconinfo.yHotspot = 0;
16 iconinfo.hbmMask = NULL;
17 iconinfo.hbmColor = NULL;
18
19 hicon = CreateIconIndirect(&iconinfo);
20 ok(hicon == 0, "should fail\n");
21
22 iconinfo.hbmMask = CreateBitmap(8, 16, 1, 1, NULL);
23 hicon = CreateIconIndirect(&iconinfo);
24 ok(hicon != 0, "should not fail\n");
25
26 ok(GetIconInfo(hicon, &iconinfo2), "\n");
27 ok_int(iconinfo2.fIcon, iconinfo.fIcon);
28 if (fIcon)
29 {
30 ok(iconinfo2.xHotspot == 4, "%ld\n", iconinfo2.xHotspot);
31 ok(iconinfo2.yHotspot == 4, "%ld\n", iconinfo2.yHotspot);
32 }
33 else
34 {
35 ok(iconinfo2.xHotspot == 0, "%ld\n", iconinfo2.xHotspot);
36 ok(iconinfo2.yHotspot == 0, "%ld\n", iconinfo2.yHotspot);
37 }
38 ok(iconinfo2.hbmMask != NULL, "iconinfo2.hbmMask was NULL\n");
39 ok(iconinfo2.hbmMask != iconinfo.hbmMask, "\n");
40 ok(iconinfo2.hbmColor == NULL, "iconinfo2.hbmColor was not NULL\n");
41
42 ok(GetIconInfo(hicon, &iconinfo2), "\n");
43 ok(iconinfo2.fIcon == iconinfo.fIcon, "\n");
44 if (fIcon)
45 {
46 ok(iconinfo2.xHotspot == 4, "%ld\n", iconinfo2.xHotspot);
47 ok(iconinfo2.yHotspot == 4, "%ld\n", iconinfo2.yHotspot);
48 }
49 else
50 {
51 ok(iconinfo2.xHotspot == 0, "%ld\n", iconinfo2.xHotspot);
52 ok(iconinfo2.yHotspot == 0, "%ld\n", iconinfo2.yHotspot);
53 }
54 ok(iconinfo2.hbmMask != NULL, "\n");
55 ok(iconinfo2.hbmMask != iconinfo.hbmMask, "\n");
56 ok(iconinfo2.hbmColor == NULL, "\n");
57
58 iconinfo.hbmColor = CreateBitmap(2, 2, 1, 1, NULL);
59 hicon = CreateIconIndirect(&iconinfo);
60 ok(hicon != 0, "should not fail\n");
61
62 ok(GetIconInfo(hicon, &iconinfo2), "\n");
63 ok_int(iconinfo2.fIcon, iconinfo.fIcon);
64 if (fIcon)
65 {
66 ok(iconinfo2.xHotspot == 4, "%ld\n", iconinfo2.xHotspot);
67 ok(iconinfo2.yHotspot == 8, "%ld\n", iconinfo2.yHotspot);
68 }
69 else
70 {
71 ok(iconinfo2.xHotspot == 0, "%ld\n", iconinfo2.xHotspot);
72 ok(iconinfo2.yHotspot == 0, "%ld\n", iconinfo2.yHotspot);
73 }
74 ok(iconinfo2.hbmMask != NULL, "\n");
75 ok(iconinfo2.hbmMask != iconinfo.hbmMask, "\n");
76 ok(iconinfo2.hbmColor != NULL, "\n");
77 ok(iconinfo2.hbmMask != iconinfo.hbmColor, "\n");
78
79 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n");
80 ok_int(bitmap.bmType, 0);
81 ok_int(bitmap.bmWidth, 8);
82 ok_int(bitmap.bmHeight, 16);
83 ok_int(bitmap.bmWidthBytes, 2);
84 ok_int(bitmap.bmPlanes, 1);
85 ok_int(bitmap.bmBitsPixel, 1);
86 ok(bitmap.bmBits == NULL, "\n");
87
88 ok(GetObject(iconinfo2.hbmColor, sizeof(bitmap), &bitmap), "GetObject failed\n");
89 ok_int(bitmap.bmType, 0);
90 ok_int(bitmap.bmWidth, 8);
91 ok_int(bitmap.bmHeight, 16);
92 ok_int(bitmap.bmWidthBytes, ((bitmap.bmWidth * bitmap.bmBitsPixel + 15) & ~15) / 8);
93 ok_int(bitmap.bmPlanes, 1);
94 ok(bitmap.bmBitsPixel == 1 || bitmap.bmBitsPixel == 2 || bitmap.bmBitsPixel == 4 ||
95 bitmap.bmBitsPixel == 8 || bitmap.bmBitsPixel == 16 || bitmap.bmBitsPixel == 32,
96 "bmBitsPixel = %u\n", bitmap.bmBitsPixel);
97 ok(bitmap.bmBits == NULL, "\n");
98
99 DeleteObject(iconinfo.hbmMask);
100 iconinfo.hbmMask = NULL;
101 hicon = CreateIconIndirect(&iconinfo);
102 ok(hicon == 0, "should fail\n");
103
104 DeleteObject(iconinfo.hbmColor);
105 iconinfo.hbmColor = CreateCompatibleBitmap(GetDC(0), 16, 16);
106 hicon = CreateIconIndirect(&iconinfo);
107 ok(hicon == 0, "should fail\n");
108
109 iconinfo.hbmMask = CreateCompatibleBitmap(GetDC(0), 8, 16);
110 hicon = CreateIconIndirect(&iconinfo);
111 ok(hicon != 0, "should not fail\n");
112
113 ok(GetIconInfo(hicon, &iconinfo2), "\n");
114
115 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n");
116 ok_int(bitmap.bmType, 0);
117 ok_int(bitmap.bmWidth, 8);
118 ok_int(bitmap.bmHeight, 16);
119 ok_int(bitmap.bmWidthBytes, 2);
120 ok_int(bitmap.bmPlanes, 1);
121 ok_int(bitmap.bmBitsPixel, 1);
122 ok(bitmap.bmBits == NULL, "\n");
123
124 ok(GetObject(iconinfo2.hbmColor, sizeof(bitmap), &bitmap), "GetObject failed\n");
125 ok_int(bitmap.bmType, 0);
126 ok_int(bitmap.bmWidth, 8);
127 ok_int(bitmap.bmHeight, 16);
128 ok_int(bitmap.bmWidthBytes, ((bitmap.bmWidth * bitmap.bmBitsPixel + 15) & ~15) / 8);
129 ok_int(bitmap.bmPlanes, 1);
130 ok(bitmap.bmBitsPixel == 1 || bitmap.bmBitsPixel == 2 || bitmap.bmBitsPixel == 4 ||
131 bitmap.bmBitsPixel == 8 || bitmap.bmBitsPixel == 16 || bitmap.bmBitsPixel == 32,
132 "bmBitsPixel = %u\n", bitmap.bmBitsPixel);
133 ok(bitmap.bmBits == NULL, "\n");
134}
135
136
138{
139 HCURSOR hcursor;
140 HICON hicon;
141 ICONINFO iconinfo2;
143 DWORD data[] = {0, 0, 0, 0, 0, 0};
144
147
148 hcursor = LoadCursor(NULL, IDC_APPSTARTING);
149 ok(hcursor != 0, "should not fail\n");
150 ok(GetIconInfo(hcursor, &iconinfo2), "\n");
151 ok(iconinfo2.fIcon == 0, "\n");
152 ok(iconinfo2.hbmMask != NULL, "\n");
153
154 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n");
155 ok_int(bitmap.bmType, 0);
156 ok(bitmap.bmWidth > 4, "bmWidth = %lu\n", bitmap.bmWidth);
157 ok(bitmap.bmHeight > 4, "bmHeight = %lu\n", bitmap.bmHeight);
158 ok_int(bitmap.bmWidthBytes, ((bitmap.bmWidth * bitmap.bmBitsPixel + 15) & ~15) / 8);
159 ok_int(bitmap.bmPlanes, 1);
160 ok_int(bitmap.bmBitsPixel, 1);
161 ok(bitmap.bmBits == NULL, "\n");
162
163 ok(iconinfo2.xHotspot < bitmap.bmWidth, "xHotspot = %lu, bmWidth = %lu\n", iconinfo2.xHotspot, bitmap.bmWidth);
164 ok(iconinfo2.yHotspot < bitmap.bmHeight, "yHotspot = %lu, bmHeight = %lu\n", iconinfo2.yHotspot, bitmap.bmHeight);
165
166 hcursor = CreateCursor(NULL, 1, 2, 4, 4, data, data);
167 ok(hcursor != 0, "should not fail\n");
168 ok(GetIconInfo(hcursor, &iconinfo2), "\n");
169 ok(iconinfo2.fIcon == 0, "\n");
170 ok_int(iconinfo2.xHotspot, 1);
171 ok_int(iconinfo2.yHotspot, 2);
172 ok(iconinfo2.hbmMask != NULL, "\n");
173 ok(iconinfo2.hbmColor == NULL, "\n");
174
175 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n");
176 ok_int(bitmap.bmType, 0);
177 ok_int(bitmap.bmWidth, 4);
178 ok_int(bitmap.bmHeight, 8);
179 ok_int(bitmap.bmWidthBytes, 2);
180 ok_int(bitmap.bmPlanes, 1);
181 ok_int(bitmap.bmBitsPixel, 1);
182 ok(bitmap.bmBits == NULL, "\n");
183
184
185 hicon = CreateIcon(0, 4, 4, 1, 1, (PBYTE)data, (PBYTE)data);
186 ok(hicon != 0, "should not fail\n");
187
188 ok(GetIconInfo(hicon, &iconinfo2), "\n");
189 ok(iconinfo2.fIcon == 0 || iconinfo2.fIcon == 1, "fIcon = 0x%x\n", iconinfo2.fIcon);
190 ok_int(iconinfo2.xHotspot, 2);
191 ok_int(iconinfo2.yHotspot, 2);
192 ok(iconinfo2.hbmMask != NULL, "\n");
193 ok(iconinfo2.hbmColor == NULL, "\n");
194
195}
void Test_GetIconInfo(BOOL fIcon)
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static HICON
Definition: imagelist.c:84
BYTE * PBYTE
Definition: pedump.c:66
Definition: bl.h:1331
DWORD yHotspot
Definition: winuser.h:3125
BOOL fIcon
Definition: winuser.h:3123
DWORD xHotspot
Definition: winuser.h:3124
HBITMAP hbmColor
Definition: winuser.h:3127
HBITMAP hbmMask
Definition: winuser.h:3126
Definition: uimain.c:89
HICON HCURSOR
Definition: windef.h:299
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
#define GetObject
Definition: wingdi.h:4468
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
Definition: cursoricon.c:2581
HICON WINAPI CreateIcon(_In_opt_ HINSTANCE, _In_ int, _In_ int, _In_ BYTE, _In_ BYTE, _In_ const BYTE *, _In_ const BYTE *)
Definition: cursoricon.c:2395
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2045
#define IDC_APPSTARTING
Definition: winuser.h:699
#define LoadCursor
Definition: winuser.h:5812
HDC WINAPI GetDC(_In_opt_ HWND)
HCURSOR WINAPI CreateCursor(_In_opt_ HINSTANCE, _In_ int, _In_ int, _In_ int, _In_ int, _In_ CONST VOID *, _In_ CONST VOID *)