Loading an Icon [WinAPI]
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
The extension for icons is .ico. To load an external icon using LoadImage(), you need to typecast the returned HANDLE to a HICON:
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement