Taskbar window button icon

I was having a problem with Windows displaying the wrong icon for my app. I added both 32x32 and 16x16 icons to my icon resource. However, the 32x32 icon was being shown on the Taskbar window button, which looked ugly.

I looked in createWindowCallback in juce_win32_Windowing.cpp and found this line just before the call to RegisterClassEx:

Changing this to:

seemed to fix the problem nicely; now, the shell just extracts the correctly sized icon from the resource and everything’s peachy.

Any reason not to have it this way? I’ve only tried this with Windows XP.


There was definitely a good reason why I used the ExtractIcon thing… can’t remember what it was though…

OK. I tried this instead:

wcex.hIcon   = ExtractAssociatedIcon (moduleHandle, moduleFile, &iconNum);
iconNum      = 1;
wcex.hIconSm = ExtractAssociatedIcon (moduleHandle, moduleFile, &iconNum);

and then added a second 16x16 icon resource. That seems to work correctly.

Perhaps this is needed for older versions of Windows.


That’s not much good if there’s only one icon though, or if they’re not in the same order.

I think the reason I added the ExtractIcon call was for DLLs rather than EXEs, because they’d pick up the host app’s icon by default instead of the DLL’s.

How about this:

wcex.hIcon = (moduleHandle == GetModuleHandle (0)) ? 0 : ExtractAssociatedIcon (moduleHandle, moduleFile, &iconNum);

(I’ve not tried this yet, but think it’ll probably work).

Well, I think it’s delicious and savory, with just a hint of nutmeg. It worked beautifully.

Thanks - that’s a better solution than mine; more general-purpose.

I appreciate it!