Windows 7 application taskbar icons, font size and shortcuts
We encountered some kind of behavior with the taskbar icons that appear in Windows 7 for different applications. I'm wondering if anyone can shed some light on this:
- Windows 7 is installed with font size = 110%.
- The two dialog applications MFC A.exe and B.exe have exactly the same .ico resource embedded in them.
- A.exe has a combination associated with it; B.exe doesn't.
- Running A.exe shows a nice interpolated system tray icon.
- Running B.exe shows a different system tray icon (not interpolated).
We would like the same icon to appear on the taskbar for A.exe and B.exe - this is easy to achieve by creating a shortcut to B.exe to give the same behavior. However, I'm really trying to figure out what's going on next.
In an attempt to understand what's going on, I processed the WM_GETICON message inside B.exe, returning the icon according to the dimensions given by the GetSystemMetrics size SM_CXICON / SM_CYICON or SM_CXSMALLICON / SM_CYSMALLICON. However, it didn't seem to affect the icon shown in the taskbar.
I also know that we could create a .ico file that will be embedded in B.exe with a lot of different sized icons - maybe that would improve things, but it's a tedious solution!
Any ideas?
a source to share
Just met this issue with the following simple script (all on win7):
- create A.exe with icon B
- create B.lnk linked to A.exe with different C icon (by winapi CreateLink)
- run by pressing B.lnk. On some win7 machines the taskbar icon is C. But on some other machine (also win7) it is B.
If the icon is C, it cannot even be changed with the following code:
const HANDLE bigicon = ::LoadImage(::GetModuleHandle(0), MAKEINTRESOURCE(IDI_TO_ICON), IMAGE_ICON, 256, 256, 0);
if (bigicon) {
::SendMessage(theMainWnd, WM_SETICON, ICON_BIG, (LPARAM)bigicon);
::SendMessage(GetWindow(theMainWnd, GW_OWNER), WM_SETICON, ICON_BIG, (LPARAM)bigicon);
}
const HANDLE smallicon = ::LoadImage(::GetModuleHandle(0), MAKEINTRESOURCE(IDI_TO_ICON_SMALL), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0);
if (smallicon) {
::SendMessage(theMainWnd, WM_SETICON, ICON_SMALL, (LPARAM)smallicon);
::SendMessage(GetWindow(theMainWnd, GW_OWNER), WM_SETICON, ICON_SMALL, (LPARAM)smallicon);
}
a source to share