1 2 #include "precomp.h" 3 4 // FIXME user32 5 6 void 7 Test_GetIconInfo(BOOL fIcon) 8 { 9 HICON hicon; 10 ICONINFO iconinfo, iconinfo2; 11 BITMAP bitmap; 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(iconinfo2.fIcon == iconinfo.fIcon, "\n"); 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, "\n"); 39 ok(iconinfo2.hbmMask != iconinfo.hbmMask, "\n"); 40 ok(iconinfo2.hbmColor == 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(iconinfo2.fIcon == iconinfo.fIcon, "\n"); 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(bitmap.bmType == 0, "\n"); 81 ok(bitmap.bmWidth == 8, "\n"); 82 ok(bitmap.bmHeight == 16, "\n"); 83 ok(bitmap.bmWidthBytes == 2, "\n"); 84 ok(bitmap.bmPlanes == 1, "\n"); 85 ok(bitmap.bmBitsPixel == 1, "\n"); 86 ok(bitmap.bmBits == NULL, "\n"); 87 88 ok(GetObject(iconinfo2.hbmColor, sizeof(bitmap), &bitmap), "GetObject failed\n"); 89 ok(bitmap.bmType == 0, "\n"); 90 ok(bitmap.bmWidth == 8, "\n"); 91 ok(bitmap.bmHeight == 16, "\n"); 92 ok(bitmap.bmWidthBytes == 8 * bitmap.bmBitsPixel / 8, "\n"); 93 ok(bitmap.bmPlanes == 1, "\n"); 94 ok(bitmap.bmBitsPixel == 32, "\n"); 95 ok(bitmap.bmBits == NULL, "\n"); 96 97 DeleteObject(iconinfo.hbmMask); 98 iconinfo.hbmMask = NULL; 99 hicon = CreateIconIndirect(&iconinfo); 100 ok(hicon == 0, "should fail\n"); 101 102 DeleteObject(iconinfo.hbmColor); 103 iconinfo.hbmColor = CreateCompatibleBitmap(GetDC(0), 16, 16); 104 hicon = CreateIconIndirect(&iconinfo); 105 ok(hicon == 0, "should fail\n"); 106 107 iconinfo.hbmMask = CreateCompatibleBitmap(GetDC(0), 8, 16); 108 hicon = CreateIconIndirect(&iconinfo); 109 ok(hicon != 0, "should not fail\n"); 110 111 ok(GetIconInfo(hicon, &iconinfo2), "\n"); 112 113 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n"); 114 ok(bitmap.bmType == 0, "\n"); 115 ok(bitmap.bmWidth == 8, "%ld\n", bitmap.bmWidth); 116 ok(bitmap.bmHeight == 16, "%ld\n", bitmap.bmHeight); 117 ok(bitmap.bmWidthBytes == 2, "%ld\n", bitmap.bmWidthBytes); 118 ok(bitmap.bmPlanes == 1, "%d\n", bitmap.bmPlanes); 119 ok(bitmap.bmBitsPixel == 1, "%d\n", bitmap.bmBitsPixel); 120 ok(bitmap.bmBits == NULL, "\n"); 121 122 ok(GetObject(iconinfo2.hbmColor, sizeof(bitmap), &bitmap), "GetObject failed\n"); 123 ok(bitmap.bmType == 0, "\n"); 124 ok(bitmap.bmWidth == 8, "%ld\n", bitmap.bmWidth); 125 ok(bitmap.bmHeight == 16, "%ld\n", bitmap.bmHeight); 126 ok(bitmap.bmWidthBytes == 32, "%ld\n", bitmap.bmWidthBytes); 127 ok(bitmap.bmPlanes == 1, "%d\n", bitmap.bmPlanes); 128 ok(bitmap.bmBitsPixel == 32, "%d\n", bitmap.bmBitsPixel); 129 ok(bitmap.bmBits == NULL, "\n"); 130 131 132 } 133 134 135 START_TEST(CreateIconIndirect) 136 { 137 HCURSOR hcursor; 138 HICON hicon; 139 ICONINFO iconinfo2; 140 BITMAP bitmap; 141 DWORD data[] = {0, 0, 0, 0, 0, 0}; 142 143 Test_GetIconInfo(0); 144 Test_GetIconInfo(1); 145 146 hcursor = LoadCursor(NULL, IDC_APPSTARTING); 147 ok(hcursor != 0, "should not fail\n"); 148 ok(GetIconInfo(hcursor, &iconinfo2), "\n"); 149 ok(iconinfo2.fIcon == 0, "\n"); 150 ok(iconinfo2.xHotspot == 0, "%ld\n", iconinfo2.xHotspot); 151 ok(iconinfo2.yHotspot == 8, "%ld\n", iconinfo2.yHotspot); 152 ok(iconinfo2.hbmMask != NULL, "\n"); 153 ok(iconinfo2.hbmColor != NULL, "\n"); 154 155 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n"); 156 ok(bitmap.bmType == 0, "\n"); 157 ok(bitmap.bmWidth == 32, "%ld\n", bitmap.bmWidth); 158 ok(bitmap.bmHeight == 32, "\n"); 159 ok(bitmap.bmWidthBytes == 4, "\n"); 160 ok(bitmap.bmPlanes == 1, "\n"); 161 ok(bitmap.bmBitsPixel == 1, "\n"); 162 ok(bitmap.bmBits == NULL, "\n"); 163 164 ok(GetObject(iconinfo2.hbmColor, sizeof(bitmap), &bitmap), "GetObject failed\n"); 165 ok(bitmap.bmType == 0, "\n"); 166 ok(bitmap.bmWidth == 32, "\n"); 167 ok(bitmap.bmHeight == 32, "\n"); 168 ok(bitmap.bmWidthBytes == 32 * bitmap.bmBitsPixel / 8, "\n"); 169 ok(bitmap.bmPlanes == 1, "\n"); 170 ok(bitmap.bmBitsPixel == 32, "\n"); 171 ok(bitmap.bmBits == NULL, "\n"); 172 173 hcursor = CreateCursor(NULL, 1, 2, 4, 4, data, data); 174 ok(hcursor != 0, "should not fail\n"); 175 ok(GetIconInfo(hcursor, &iconinfo2), "\n"); 176 ok(iconinfo2.fIcon == 0, "\n"); 177 ok(iconinfo2.xHotspot == 1, "%ld\n", iconinfo2.xHotspot); 178 ok(iconinfo2.yHotspot == 2, "%ld\n", iconinfo2.yHotspot); 179 ok(iconinfo2.hbmMask != NULL, "\n"); 180 ok(iconinfo2.hbmColor == NULL, "\n"); 181 182 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n"); 183 ok(bitmap.bmType == 0, "\n"); 184 ok(bitmap.bmWidth == 4, "%ld\n", bitmap.bmWidth); 185 ok(bitmap.bmHeight == 8, "%ld\n", bitmap.bmHeight); 186 ok(bitmap.bmWidthBytes == 2, "%ld\n", bitmap.bmWidthBytes); 187 ok(bitmap.bmPlanes == 1, "\n"); 188 ok(bitmap.bmBitsPixel == 1, "\n"); 189 ok(bitmap.bmBits == NULL, "\n"); 190 191 192 hicon = CreateIcon(0, 4, 4, 1, 1, (PBYTE)data, (PBYTE)data); 193 ok(hicon != 0, "should not fail\n"); 194 195 ok(GetIconInfo(hicon, &iconinfo2), "\n"); 196 ok(iconinfo2.fIcon == 0, "\n"); 197 ok(iconinfo2.xHotspot == 2, "%ld\n", iconinfo2.xHotspot); 198 ok(iconinfo2.yHotspot == 2, "%ld\n", iconinfo2.yHotspot); 199 ok(iconinfo2.hbmMask != NULL, "\n"); 200 ok(iconinfo2.hbmColor == NULL, "\n"); 201 202 } 203