I am working on some programmatic pop-up windows, most things are working fine, there's only one exception.
I am trying to set it up so that I can specify whether to use standard or large icons in the pop-up windows. Unfortunately, there is a glitch in my understanding of LoadImage (I'll be nice, besides it's probably me). To test the large icon code, I'm setting the value directly, normally I'd have a way to select between normal and large but that's not the part that's giving me headaches.
uint8_t iIconSize = 64;
HICON hIconDlgType = static_cast<HICON>(::LoadImage(NULL, MAKEINTRESOURCE(IDI_ERROR), IMAGE_ICON, iIconSize, iIconSize, LR_DEFAULTCOLOR | LR_SHARED));
What I need to know is EITHER what the bug is in my existing code, OR if I can't do it this way, how to resize an icon that has been loaded in by this method. (I need to use system-provided icons for this, so I don't get to use files.)
I'm using Visual Studio 2022 for this.
It makes absolutely no difference what iIconSize is set to, this will load in 32x32 version of the error icon. I was expecting an icon of the specified size (in this case 64x64).
I have tried IDI_INFORMATION and IDI_WARNING to determine if there's an issue with the icon file for IDI_ERROR, but I get the same result.
As I understand it, LoadImage should use the largest valid size of an icon that is equal to or smaller than the size being asked for. The documentation certainly suggests there's a standard 64x64 icon, that you're not restricted to 32x32, and also suggests that the image should be scaled up to the requested size. Neither of these is happening.
I have also tried replacing LoadImage() with LoadIconWithScaleDown() but Visual Studio choked on the MAKEINITRESOURCE(IDI_ERROR) - it complains that LPSTR is incompatible with PCWSTR.