![](/img/trans.png)
[英]How do I set window titlebar icon and alt-tab icon in SDL2 / C++ / Visual Studio 2012 express program?
[英]How to change icon of: taskbar, in the top left corner, icon when Alt-Tab is pressed, of my .exe
平台:Windows 7
IDE:VS2013
語言:C ++
Windows類:WinAPI
我有一個自定義圖片:Icon.png。
我也有一個來自msdn示例代碼的Windows類,用於創建基本的Win32窗口。 我的Windows類結構有兩個東西hIcon和hIconSm,我不確定它們分別對應什么,但是它們可能都與圖標有關。
我需要:將任務欄的圖標更改為Icon.png,對exe左上角的圖標執行相同的操作,並更改按alt + tab時顯示的圖標。
因此,這意味着我需要知道要更改的變量,要使用的功能以及其參數代表什么。 另外,如果需要單擊VS或創建其他文件,我還需要有關如何執行此操作的說明。
任何幫助是極大的贊賞。
附言:我嘗試了其他人在這里發布的內容,但是它要么無效,要么說明不清晰,因此我要求提供詳細信息。
因此,我找到了自己的答案。
A)我可以干預資源加載(我確實這樣做了,但是在將其鏈接到LoadIcon函數時感到沮喪且失敗了。
B)第二種方式:使用LoadImage並將返回值強制轉換為HICON(顯然是hacky,但是它適用於我嘗試更改的所有圖標!!!!),因此,問題解決了哈。
windowclass.hIcon = (HICON) LoadImage( // returns a HANDLE so we have to cast to HICON
NULL, // hInstance must be NULL when loading from a file
"iconfile.ico", // the icon file name
IMAGE_ICON, // specifies that the file is an icon
0, // width of the image (we'll specify default later on)
0, // height of the image
LR_LOADFROMFILE| // we want to load a file (as opposed to a resource)
LR_DEFAULTSIZE| // default metrics based on the type (IMAGE_ICON, 32x32)
LR_SHARED // let the system release the handle when it's no longer used
);
因此,如果您要在上面進行其他自定義,建議您轉到MSDN的LoadImage定義並根據它自定義參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.