Reputation: 22178
I am porting an old (Visual Studio 6.0) application to Visual Studio 2012 in order to add some enhancements. The application's icon in the resources view clearly has 2 versions of the icon, a 32x32 4bit bitmap and a 16x16 4bit bitmap.
In the main AppDlg.cpp there are 2 calls to SetIcon()
as follows (created by default by MFC app wizard):
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
However, the icon displayed in the top left corner of the application's dialog window is the larger one, scaled down to 16x16 instead of the small one. Its also happening for the icon shown in the system tray.
It seems it uses the correct small one for the executable file when viewing it in Windows Explorer (detailed view / list view). So it is picking the small one in some circumstances.
How do I make it choose the smaller 16x16 icon for the top left corner of the dialog box and System tray?
Upvotes: 3
Views: 6608
Reputation: 10411
Known Microsoft bug. See this discussion. (if you do not want to read, just comment out SetIcon(m_hIcon, FALSE) line and you'll be fine). Please note, that SetIcon only sets the icon on the dialog title bar (small icon) and when you use Alt-tab (big icon)
The icons you see in the Windows Explorer are the main Application Icons (the icon with the lowest ID in you rc file). It has nothing to do with the main dialog's SetIcon() method
The icon in the System Tray is something completely different. Normally, you would use Shell_NotifyIcon API to set the icon, but I bet your project would have a helper class that sets the icon CSystemTray by Chris Maunder is a popular one used by many programmers. Just search for Shell_NotifyIcon in your program to find out exactly what resource is used for the system tray icon
Upvotes: 3