Setting Custom Icon in the Titlebar - Win32api

I've asked a similar question before but was using wxWidgets ( http://cplusplus.com/forum/windows/23540/ ). Now I am trying to learn the Win32api and am using the MinGW compiler. I was able to figure out how to set the titlebar icon using an external .ico file with this code:

wincl.hIconSm = (HICON)LoadImage(NULL, "eye.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);


What I want to do is set the icon from the exe's resources. I have created a resource file:

IDI_EYE ICON "eye.ico"


And defined the icon in the source:

#define IDI_EYE 201


But I don't know where to go from there. I've tried the following, it compiles but does not display my icon.

wincl.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_EYE), IMAGE_ICON, 16, 16, 0);
The titlebar icon is defined with wincl.hIcon:
 
wincl.hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_EYE), IMAGE_ICON, 16, 16, 0);
Did you include your header file in the resource file?

@Null: Actually, hIcon just defines the icon displayed on the taskbar, however, if hIconSm is null, hIcon will be searched for an appropriate image in the hIcon handle.
@Vexer: if he wouldn't then it wouldn't compile.

It sounds like it should work. Make sure the resource path is relative to the .RC file, not the .exe file, and ensure that 201 is a valid resource ID.
Topic archived. No new replies allowed.