简体   繁体   中英

How to change icon of: taskbar, in the top left corner, icon when Alt-Tab is pressed, of my .exe

Platform: Windows 7

IDE: VS2013

Language: C++

Windows class: WinAPI

I have a custom image: Icon.png.

I also have a windows class from the msdn sample code to create a basic Win32 window. It has two things hIcon and hIconSm of my windows class structure which I am not sure what they correspond to, but they both are probably related to icons.

I need to: Change the icon of the taskbar to Icon.png, do same thing for the icons in top left corner of the exe, and change the icon which displays when alt+tab is pressed.

So that means I need to know which variables I change, what functions to use, and what its parameters stand for. Also if any clicking in VS or additional file creation is needed I also need instructions on how to do that.

Any help is greatly appreciated.

PS I tried the stuff posted by other people on here but it either didn't work or the instructions were unclear, hence my asking for specifics.

So, I found my own answer.

A) I could meddle with resource loading (which I did, and came out frustrated and unsuccessful at linking it to the LoadIcon function.

B) Second way: Use LoadImage and cast return value to HICON (hacky apparently, but it worked for all icons I was trying to change!!!!! So, problem solved hah. Below is the pseudocode I used into my project.

   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
   );

So, if you want some other customization to above, I recommend going to MSDN definition of LoadImage and customize your parameters according to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM