Jump to content
  • Advertisement
Sign in to follow this  
stenny

Loading an Icon [WinAPI]

This topic is 4282 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

G'day[smile], I was wondering, how I could load and external Iconfile and use it as the Icon of my Application. I've got a file called 'Icon' in the same folder as the exe, but I don't know what exactly to use. I've tried something like: m_wcex.hIcon = LoadImage(m_hInst, "Icon", IMAGE_ICON, NULL, NULL, LR_LOADFROMFILE); But LoadImage returns a HANDLE, and I don't know how to use LoadIcon (and the msdn I should use LoadIcon). Also, I haven't got a clue what the extension of an icon is, and whether I need to use WNDCLASSEX.hIcon or WNDCLASSEX.hIconSm. Could someone help? -Stenny

Share this post


Link to post
Share on other sites
Advertisement
The extension for icons is .ico. To load an external icon using LoadImage(), you need to typecast the returned HANDLE to a HICON:

m_wcex.hIconSm = HICON(LoadImage(NULL, 
"Icon.ico",
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CXSMICON),
LR_LOADFROMFILE));



Also, the member hIcon specifies the icon for the class, whereas hIconSm determines the small icon used in the application's title bar.

Hope this helps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!