| 1332 | |
| 1333 | |
| 1334 | ResultType UserMenu::SetItemIcon(UserMenuItem *aMenuItem, LPTSTR aFilename, int aIconNumber, int aWidth) |
| 1335 | { |
| 1336 | if (!*aFilename || (*aFilename == '*' && !aFilename[1])) |
| 1337 | return RemoveItemIcon(aMenuItem); |
| 1338 | |
| 1339 | int image_type; |
| 1340 | HBITMAP new_icon, new_copy; |
| 1341 | // Currently height is always -1 and cannot be overridden. -1 means maintain aspect ratio, usually 1:1 for icons. |
| 1342 | if ( !(new_icon = LoadPicture(aFilename, aWidth, -1, image_type, aIconNumber, false)) ) |
| 1343 | return FAIL; |
| 1344 | |
| 1345 | if (image_type != IMAGE_BITMAP) // Convert to 32-bit bitmap: |
| 1346 | { |
| 1347 | new_copy = IconToBitmap32((HICON)new_icon, true); |
| 1348 | // Even if conversion failed, we have no further use for the icon: |
| 1349 | DestroyIcon((HICON)new_icon); |
| 1350 | if (!new_copy) |
| 1351 | return FAIL; |
| 1352 | new_icon = new_copy; |
| 1353 | } |
| 1354 | |
| 1355 | if (aMenuItem->mBitmap) // Delete previous bitmap. |
| 1356 | DeleteObject(aMenuItem->mBitmap); |
| 1357 | |
| 1358 | aMenuItem->mBitmap = new_icon; |
| 1359 | |
| 1360 | if (mMenu) |
| 1361 | ApplyItemIcon(aMenuItem); |
| 1362 | |
| 1363 | return aMenuItem->mBitmap ? OK : FAIL; |
| 1364 | } |
| 1365 | |
| 1366 | |
| 1367 | // Caller has ensured mMenu is non-NULL. |
nothing calls this directly
no test coverage detected