soconne

Is there a way to do this during runtime AFTER the window has been created


Re: Visual C++ General Win32 C++: How do I change the window icon during runtime?

Aleksandr Tokarev

SetClassLong(hWnd, GCL_HICON, icon);

or

CWindow:: SetIcon

or

CWnd:: SetIcon

or

SendMessage(hWnd, WM_SETICON, ICON_BIG, icon);

SendMessage(hWnd, WM_SETICON, ICON_SMALL, icon);





Re: Visual C++ General Win32 C++: How do I change the window icon during runtime?

soconne

Awsome, thanks! Using SendMessage works perfectly. I got it to work for loading an icon from the disk, but it does not work for loading a 24bit or 256 color bmp from the disk.

My code for the icon is:

HANDLE icon = LoadImage(fgDisplay.Instance, "c:\\icon.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
SendMessage(instance, (UINT)WM_SETICON, ICON_BIG, (LPARAM)icon);

This works fine. Here is the code for loading the .bmp from disk, which doesn't work.

HANDLE icon = LoadImage(fgDisplay.Instance, "c:\\icon.bmp", IMAGE_BITMAP, 32, 32, LR_LOADFROMFILE);
SendMessage(instance, (UINT)WM_SETICON, ICON_BIG, (LPARAM)icon);

And again, I've tried a 24bit bitmap and 8bit.