Problems with setting application icon

前端 未结 5 1896
伪装坚强ぢ
伪装坚强ぢ 2021-01-05 14:53

(I\'m using Visual Studio 2008, though I remember having similar problems with older versions as well.)

I\'ve tried several different methods (many of them mentioned

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-05 15:11

    I've revisited this to see if I can close out my question. I have been unable to get the app's icon to show up in the alt-tab list just through embedding it in the executable; it will show up in the taskbar, as the file's icon in Explorer, and elsewhere just fine.

    I figured I'd try something simpler for setting the icon manually, and went with LoadIcon() instead, as the code below shows:

    HICON hIcon = LoadIcon( GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1) );
    if( hIcon )
    {
       SendMessage( GetHandle(), WM_SETICON, ICON_BIG, (LPARAM)hIcon );
       DestroyIcon( hIcon );
    }
    // ... Same for ICON_SMALL
    

    This seems to have done the trick. I really don't know why, but so far it's the only change that had any effect. It's really not an issue I should spend any more time on, so I'll just go with this.

提交回复
热议问题