- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there an example of displaying a bitmap in a button for a windows api project?
In the button properties - style tab, there is a check box for bitmap.
Is there an example, or can anyone tell me how to do it.
Thanks,
David
In the button properties - style tab, there is a check box for bitmap.
Is there an example, or can anyone tell me how to do it.
Thanks,
David
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After some searching I found some code to try, but it doesn't work.
I'm sure why, there is probably a small error with the code.
On the SendDlgItemMessage, I get an error 1421- "Control ID not found"
is that hIDDlgItem, or hImagen that it cannot find, they seam to be OK?
Thanks,
David
I'm sure why, there is probably a small error with the code.
On the SendDlgItemMessage, I get an error 1421- "Control ID not found"
is that hIDDlgItem, or hImagen that it cannot find, they seam to be OK?
hIDDlgItem=GetDlgItem(hWnd,IDC_BUTTON1) FileName="c:MyBitmap.bmp"//char(0) hImagen=LoadImage(hInst,FileName,IMAGE_BITMAP,32,32,LR_DEFAULTSIZE.OR.LR_LOADFROMFILE) iret=SendDlgItemMessage(hwnd,hIDDlgItem,BM_SETIMAGE,IMAGE_BITMAP,hImagen) iret=GetLastError()
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Second argument to SendDlgItemMessage is control's ID, not handle ;-).
Also, don't forget to add BS_BITMAP style to your button.
Jugoslav
Also, don't forget to add BS_BITMAP style to your button.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the quick response, that fixed it.
I simplified it a bit more by having the bitmap as a resource rather than specify the file name.
I simplified it a bit more by having the bitmap as a resource rather than specify the file name.
hImage=LoadImage(hInst,IDB_MYBITMAP,IMAGE_BITMAP,32,32,LR_DEFAULTSIZE) iret=SendDlgItemMessage(hwnd,IDC_BUTTON1,BM_SETIMAGE,IMAGE_BITMAP,hImage)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page