4

I'm using LoadIcon for loading system icons such as the "Attention" sign. This works fine, but this gives me the icon with the old (I think) Windows 7 look.

My program runs on Windows 10.

Code:

hicon = LoadIcon(NULL, IDI_EXCLAMATION);

enter image description here

Is there a way to get the icons with the new look?

On the other hand MessageBox with the MB_ICONEXCLAMATION flag shows the new icon.

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
  • Have you tried with LoadImage(..., IMAGE_ICON, ...)? – Simon Mourier Mar 27 '20 at 15:03
  • @SimonMourier no, and I wouldn't know how. – Jabberwocky Mar 27 '20 at 15:14
  • How do you learn anything? You read the documentation. – David Heffernan Mar 27 '20 at 15:18
  • @DavidHeffernan I've read the documentation of `LoadImage`, but maybe I didn't understand everything. Is it about OEM images? – Jabberwocky Mar 27 '20 at 15:27
  • look for https://stackoverflow.com/questions/54826050/how-to-load-a-timage-using-task-dialog-common-icons the MessageBox actually load icon from *imageres.dll* with `0x54` id – RbMm Mar 27 '20 at 15:33
  • @RbMm thanks, that's somewhat helpful. But loading from imageres.dll is maybe not the best option, because it's an implementation detail, e.g. would this work on Windows 7? – Jabberwocky Mar 27 '20 at 15:46
  • @DavidHeffernan when I commented "no, and I wouldn't know how", it wasn't about how to use `LoadImage` but it about how using `LoadImage` to that the modern icons show. – Jabberwocky Mar 27 '20 at 16:04
  • @SimonMourier It doesn't help, I get the old fashioned icons with `LoadImage`. – Jabberwocky Mar 27 '20 at 16:04
  • 2
    ok - [`LoadIconWithScaleDown`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-loadiconwithscaledown)`(0, IDI_EXCLAMATION, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), &hi);` do task – RbMm Mar 27 '20 at 16:10

1 Answers1

8

I saw that MessageBoxW uses the LoadIconWithScaleDown function for loading icons instead of LoadImage or LoadIcon. With standard icon IDs (from 0x7f00 (IDI_APPLICATION..IDI_SHIELD) this function actually loads images from imageres.dll (while LoadImage loads them from user32.dll).

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
RbMm
  • 31,280
  • 3
  • 35
  • 56
  • Fastest, upvote +accept!! I just figured out how to do it with `LoadIconWithScaleDown`! Thanks! – Jabberwocky Mar 27 '20 at 16:21
  • 2
    @Jabberwocky - https://i.imgur.com/6GxdfFK.png this is how `LoadIconWithScaleDown` redirect standard icons to *imageres.dll* - `IDI_EXCLAMATION` - 0x7F03 is redirected to 0x54 from *imageres.dll*. strange that `LoadImage` not do the same and this not documented – RbMm Mar 27 '20 at 16:24