Skip to main content
GameDev.net gamedev.net
🔒 Locked

How to change a window's icon after it has been created?

Started by CodaKiller May 21, 2009 at 1:53 PM 2 replies 650+ views
Original Post
CodaKiller
CodaKiller
I need to change the icon of my window dynamically, when I created it I used LoadImage to load the icon then passed it to the hIcon property of the WNDCLASSEX class. Now I would like to load a new icon and set the window icon to it after the window has been created, so how could I do this? Also is there a way to get the file name of the current icon the window is using?
Remember Codeka is my alternate account, just remember that!
Zakwayda
Zakwayda
I don't know about getting the filename of the current icon, but for setting the window icon, take a look at SetClassLongPtr().
CodaKiller
CodaKiller
Quote:
Original post by jyk
I don't know about getting the filename of the current icon, but for setting the window icon, take a look at SetClassLongPtr().


Tried it and nothing happened but it did lead me to something that worked:

		HANDLE icon = LoadImage(NULL, file.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);		SendMessage(hWnd, (UINT)WM_SETICON, ICON_BIG, (LPARAM)icon);


Thanks though!
Remember Codeka is my alternate account, just remember that!
Evil Steve
Evil Steve
Quote:
Original post by CodaKiller
Also is there a way to get the file name of the current icon the window is using?
No, there is no way to do this - You never pass the filename of an icon to windows, it doesn't have any way to find out if a HICON is loaded from a file and get the filename the resource was loaded from.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.