I made an icon to go with my program the other day, and I placed it in a resource file and compiled it. It immediatley changed so that my .exe had the icon representing it. I didn't think it would work that easy (never done that before). But when I opened my program I still have the default on the titlebar.
I know I can change it while the window is being created, however that's buried in my OpenGL window framework that I do not want to change so that I need to include an icon load into it. I want to just change my icon at runtime. I looked up some
stuff on MSDN and found these two methods, but they are not working.
They compile, but none have an effect when executed. Note that GetHWND() just returns the handle to my main window, and it DOES work.
rsc.h, defines my 32x32 .ico file
#define IDR_ICO_MAIN 411
HICON hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_ICO_MAIN));
SendMessage(GetHWND(), WM_SETICON, ICON_BIG, (LPARAM) hIcon );
SendMessage(GetHWND(), WM_SETICON, ICON_SMALL, (LPARAM) hIcon );
SetClassLong(GetHWND(),GCL_HICON,(LONG)
LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_ICO_MAIN)));