Home
Tutorials
Code Snippets
Code Samples
Downloads
Links

The Blog
Our Projects
About
Contact

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

 
Code Snippet - Icon Changing
Author:Arkon
Category:Win32API
File Size:507 Bytes
Uploaded at:27-Nov-02 03:19:08 pm
Description:
  Change your application's icon in runtime.
  
// Setting/changing an icon to a window(CLASS)

// From resource
HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));

// From file:
HICON hIcon = LoadImage(hInstance, "filename.ico", IMAGE_ICON, SM_CXICON, SM_CYICON, LR_LOADFROMFILE | LR_DEFAULTSIZE);


SetClassLong(hWnd, GCL_HICON, (LONG)hIcon);

// Or...
SendMessage(hWnd, WM_SETICON, WM_SMALL, (LPARAM)hIcon); // The icon on the task-bar
SendMessage(hWnd, WM_SETICON, WM_BIG, (LPARAM)hIcon); // The icon on the ALT+TAB dialog box
User Contributed Comments(1)
 [1] arkon | 2007-03-09 14:09:20

WM_SMALL and WM_BIG are actually ICON_SMALL and ICON_BIG.

Trying to apply a new big icon for a child window won't work, it uses its parent window's icon!
NOTE:
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
Name:
email:
Comment:
::Top 5 Tutorials::
Embedded Python[106775]
2D Rotated Rectangles Collision Detection[79918]
Keyboard Hook[69063]
UDP[53058]
HTTP Proxy[36303]

::Top 5 Samples::
2D ColDet Rotated Rectangles[10638]
PS2 Mouse Driver[6122]
Wave Format Player[5005]
Reading FAT12[4893]
CodeGuru[4579]


All rights reserved to RageStorm © 2009