ICON to CButton

Hello,
I'm using VC6++ and MFC. I have created a CButton with property Symbol and I want to display an Icon on that Button.
The Icon is for example the normal trash icon from windows (its included to resources as IDI_TRASH
But it does not work to do the following:
HINSTANCE hInst;
HICON TEST;
TEST = LoadIcon(hInst, LPCTSTR(IDI_TRASH);
m_TEST.SetIcon(TEST);
UpdateData(TRUE);
What did I wrong?
MIKE2SAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
nietodConnect With a Mentor Commented:
The first parameter to LoadIcon is an instance handle to the module that contains the resource you want to load.   A modlue is either an EXE or DLL)  So you need to know what EXE/DLL specifies the resource.  Do you?  There is one other posibility, if the resource is from the OS, that is, it was not created by you and is not stored in your EXE/DLL, then specify NULL for this

Does that help you locate it?
0
 
nietodCommented:
Did you test to see if LoadIncon() returned a non-NULL handle?

Do you initialize hInst?  It looks like you don't.
0
 
MIKE2SAuthor Commented:
No I didn't init hInst. How to init?
Yes loadicon returns with a NULL.

0
 
MIKE2SAuthor Commented:
Yes it works!!
Thanks
0
All Courses

From novice to tech pro — start learning today.