Putting icons in buttons using Win32 api..

Started by
8 comments, last by FlyingDemon 20 years ago
How would I send or put an icon (thats specified in a resource file) onto a button using the Win32 api?
Advertisement
BM_SETIMAGE

Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud
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]
Is is that you want an icon and text or just an icon?
I need just an icon... Im trying to make something along the lines of a tool bar but with a dialog(which is created in a resource file)
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.
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]
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?
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.
Why dont you fucktards get a name. Then make yourself a post to fight in.

This topic is closed to new replies.

Advertisement