Jonas Byström
Jonas Byström

Reputation: 26169

Win32 CreateWindowEx() window icon not showing properly

I create my window using CreateWindowEx, but I only get an icon in the task bar; both the window's title bar and the icon that shows when I Alt+Tab show this type of dummy icon: default Windows icon. I set both the hIcon and the hIconSm fields in the WNDCLASSEX to the value returned from ::LoadIcon(hInstance, IDI_APPLICATION) (not NULL).

The .ico file itself was made out of a .png which I genereated through http://converticon.com to 16x16, 32x32 and 96x96 (what are the recommended sizes btw?). Could it be that I'm using the wrong sizes or color depth? If so, why does it work in the task bar (different size)? Thanks!

Upvotes: 1

Views: 3780

Answers (1)

Brian
Brian

Reputation: 159

The icon must be defined as a resource somewhere. In your resource header there should be a line like this:

#define IDI_MYICON 1000

Then in your call to LoadIcon() it should be something like:

wc.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_MYICON));

If you're using Visual Studio it's pretty easy to add resources. Just right click Resources in the solution explorer.

Upvotes: 5

Related Questions