Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display an icon on a button

Status
Not open for further replies.

nanzp

Programmer
Feb 24, 2000
10
IE
Hi all,<br>
Could anyone tell me how to display an icon on a button with text in a dialog.<br>
I have come across the SetIcon method that takes a HICON as parameter but how to I get the handle to an icon that is a resource?<br>
Thanks in advance,<br>
Ann
 
Hi Ann!<br>
<br>
You can do something like this:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;HICON&nbsp;&nbsp;&nbsp;&nbsp;h;<br>
&nbsp;&nbsp;&nbsp;&nbsp;h = (HICON)LoadResource(hInstance, FindResource(hInstance, szName, RT_ICON));<br>
<br>
Where hInstance is the instance handle of the module you want to get the resource from (NULL for current module), and szName is the name of the resource, or perhaps a resource ID (see MSDN for details).<br>
<br>
You can call LockResource(h) to access the raw resource information, and cast it to an icon structure.<br>
<br>
Don't forget to call DestroyIcon(h) when you are done with it. <br>
<br>
Chip H.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top