0
votes

I had trouble finding documentation for doing this. Found some other posts here, but I'm still having trouble getting this to work. Here is what I've tried:

I added the .ico file from my file system as as an icon resource to my project and am using the default ID of IDI_ICON1.

I then modified resources.h and changed the IDI_ICON1 value to be the lowest in the list (101).

In my code I'm calling LoadIcon like so:

hIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON1));

I then clean and build my project, but it is still using the previous IDI_EXCLAMATION icon.

Any ideas what I am missing?

1
Hm, so in explorer the icon for my .exe is set how I expect. But in the taskbar and in the pop-up dialog it is not. I found a call to SetIcon later on in the code and when I remove that, my icon shows in the taskbar correctly, but still not in the dialog that is open. So it seems like the "default" icon for the dialog window is overriding my custom icon.Axl

1 Answers

0
votes

When Explorer needs to display an icon in say a folder window it retrieves the icon directly from the executable. The taskbar however uses the icon associated with an application window. You can specify the icon to use by setting it in the instance of WNDCLASS passed to RegisterClass. You can also change it after the window has been created by using the WM_SETICON window message.

For the dialog window you can use the WM_SETICON window message in the same way when you handle the WM_INITDIALOG message when the dialog is created.