I have a CWnd window which I create dynamically, and it seems that the icon for title bar area and task bar is picked at random or something.
To set the icon, I call:
// Set the icon for this dialog. The framework does this automatically when the application's main window is not a dialog
m_hIcon = AfxGetApp()->LoadIconW(IDI_ICON);
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
As in MFC samples, but it seems that the 32x32 icon is always chosen and downscaled, even though there are other, closer matches available. The icon in the title bar is actually only 16x16, but it gets created from 32x32 version.
This causes a mess when 32x32 icon is more detailed than the 16x16 one, as the downscale开发者_运维问答d icon looks like a blur.
CFrameWnd windows seem to behave differently somehow, as they seem to choose closer match.
Does anyone know a solution to force feed smaller icon in title bar so that I could keep the larger icons for W7 task tray?
It is LoadIcon, not LoadIconW, this compiles by accident. The MFC method uses the LoadIcon() API function. From the SDK documentation:
LoadIcon can only load an icon whose size conforms to the SM_CXICON and SM_CYICON system metric values. Use the LoadImage function to load icons of other sizes.
Use LoadImage() instead so you can pass an appropriate size. Make two calls to retrieve a large and a small version. Or store the small icon image in another icon with another resource ID.
精彩评论