Archived

This topic is now archived and is closed to further replies.

FlyingDemon

Putting icons in buttons using Win32 api..

Recommended Posts

OK..

After countless trys and many MSDN+Google webpages, I just cant seem to get it to work.

HICON Icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDICON_MY_ICON));

SendDlgItemMessage(winMainDialog, IDC_TVIEW_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Icon);

Where:
IDICON_MY_ICON is defined in a resource file as an ICON

winMainDialog is the HWND of the dialog that has the buton

IDC_TVIEW_BUTTON is the button's ID (defined in a header)

And were LoadIcon does NOT return a NULL value.

So im stumped..




[edited by - FlyingDemon on March 30, 2004 9:47:42 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Does the button in question have the BS_ICON style?

Note, that, one shouldn''t even have to ask this. Provide more information next time.

Share this post


Link to post
Share on other sites
HA. None of the various win32 api button tutorials said that the button needed a BS_ICON style to put an image on it. Let me see if this is what im missing.

EDIT:
Thanks AP for the fix. It works now.

[edited by - FlyingDemon on March 31, 2004 1:40:44 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Anonymous Poster
Note, that, one shouldn''t even have to ask this. Provide more information next time.


And how is he supposed to tell you that information if he has never heard of it in the first place then?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Anonymous Poster
quote:
Original post by Anonymous Poster
Note, that, one shouldn''t even have to ask this. Provide more information next time.


And how is he supposed to tell you that information if he has never heard of it in the first place then?



A short test case would have revealed this information, and hence the problem, immediatly.

The more information the better. Always.

Share this post


Link to post
Share on other sites