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 08: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 19: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[116799]
2D Rotated Rectangles Collision Detection[88709]
Keyboard Hook[77096]
UDP[65766]
HTTP Proxy[41155]

::Top 5 Samples::
2D ColDet Rotated Rectangles[11549]
PS2 Mouse Driver[6946]
Wave Format Player[5780]
Reading FAT12[5607]
CodeGuru[5346]


All rights reserved to RageStorm © 2009