开发者

Windows 7 application taskbar icons, font size and shortcuts

We have 开发者_JAVA百科come across some behaviour involving the taskbar icons that Windows 7 displays for different applications. I'm wondering whether anybody could shed some light on this:

  • Windows 7 is set with font-size = 110%.
  • Two MFC dialog applications A.exe and B.exe have exactly the same .ico resource embedded in them.
  • A.exe has a shortcut associated with it; B.exe does not.
  • Running A.exe shows a nice interpolated icon on the taskbar.
  • Running B.exe shows a different icon on the taskbar (not interpolated).

We would wish that the same icon appears on the taskbar for A.exe and B.exe - this is easily achieved by making a shortcut to B.exe to give the same behaviour. However, I'm really trying to understand more on what's going on.

In trying to understand what was going on I have handled the WM_GETICON message inside B.exe, returning an icon according to the sizes given by GetSystemMetrics SM_CXICON/SM_CYICON or SM_CXSMALLICON/SM_CYSMALLICON size. However, this didn't seem to affect the icon shown in the taskbar.

I also know that we could create an .ico file to be built into B.exe with lots of different sizes of icons - maybe this would improve things, but that's a tedious solution!

Any ideas?


Just met this issue with following simple scenario(all on win7):

  1. create A.exe with icon B
  2. create B.lnk associated to A.exe with different icon C (by winapi CreateLink)
  3. run with clicking B.lnk. On some win7 machines, taskbar's icon is C. But, on some other machine(also win7), it's B.

If the icon is C, it even can't be changed by 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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜