Here is a peculiar issue I just encountered in Windows.
I’m using an icon (.ico) for my app, and I’m following the example of the Jucer project, which has an .ico file that gets attached via an .rc file in Visual Studio.
I’m using native title bars for my app, and the weird thing is that the icon in the title bar is the 32-pixel version scaled to 16 pixels, not the 16-pixel version. But, the 16-pixel version does get correctly used for other places (like Windows Explorer).
My 16-pixel and 32-pixel icons aren’t exactly alike, so that’s why this is bothering me at the moment.
I’m using Visual Studio 2008 if that matters.
Anyone else experiencing this or know how to fix it?
FYI, the Introjucer has the same issue.
Perhaps the title bar icon is actually more than 16 pixels high? If that was the case, the OS would probably choose a bigger one and scale it down, rather than scaling up a smaller one.
After much trial and error I figured this out. Basically it has to do with the WNDCLASSEX struct. The wcex.hIconSm member has to be set to a separate icon from the main one (wcex.hIcon). Which means that the Juce library code is fine as it is, but for any project using Juce you need to have an .rc file that looks something like this:
IDI_ICON1 ICON DISCARDABLE "icon.ico"
IDI_ICON2 ICON DISCARDABLE “icon2.ico”
And both those icons would have to be included in the project obviously. And the second one can only have one 16-pixel icon, I believe.
Hope that helps anyone out there.
[quote=“MusicMan3001”]IDI_ICON1 ICON DISCARDABLE "icon.ico"
IDI_ICON2 ICON DISCARDABLE “icon2.ico”[/quote]
What are the values of IDI_ICON1 and IDI_ICON2? I use a hand-crafted .rc file, there are no includes. It is quite minimal - all my resources are brought in via BinaryBuilder. Except for a very small handful of resources that Windows expects to see. Like the icons (or the VERSION resource).
I don’t think it actually matters. If you look at WindowClassHolder() in juce_win32_Windowing.cpp, you’ll notice that it goes:
wcex.hIcon = ExtractAssociatedIcon (moduleHandle, moduleFile, &iconNum);
iconNum = 1;
wcex.hIconSm = ExtractAssociatedIcon (moduleHandle, moduleFile, &iconNum);
So the main thing is that the “generic” icon is listed first in your .rc file, and the small one is listed second.
Old thread, but same issue.
I provide a 16x16-sized PNG for "Icon Small" in Introjucer, and a 1024x1024-sized PNG for "Icon Large" in Introjucer. However, windows fails to use the 16x16-icon for the titlebar icon.
I tried to create an icon2.ico file that only contains the 16x16-icon, and use that for IDI_ICON2 in the rc-file. Then it works fine, but gets overwritten by Introjucer each time project is re-generated.
Could the Introjucer do this automatically? Or what would the preferred fix be?