Archived

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

Bitmap in buttons?

This topic is 5776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on a level editor for a game that I''m making, and I am wondering how I can make buttons with a bitmap. I place the buttons in a modeless dialogbox, where the user can select different "tiles" by clicking on the buttons. I want the button to look pressed when selected. How can I do this in Visual C++ 6.0? All I need to know is how to make a button with an image in it? Thanks for your time and help!

Share this post


Link to post
Share on other sites
No, I am sorry... I was tired last night so I forgot to tell that I''m not using MFC... Can it be done with the Dialog Resource editor somehow? When I add buttons to my dialog, there is a check box saying BITMAP... How can I add the graphics to these buttons? Thanks!

Share this post


Link to post
Share on other sites
You have to manually load the images in the WM_INITDIALOG message and associate them with the button as follows:

/* Load the button images */
hBmpRotateAntiClockwise = (HBITMAP)LoadImage( hInst,MAKEINTRESOURCE(IDB_ROTATE_ANTI_CLOCKWISE), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );

hBmpRotateClockwise = (HBITMAP)LoadImage( hInst, MAKEINTRESOURCE(IDB_ROTATE_CLOCKWISE), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );

/* Now attatch the bitmaps to the buttons */
SendDlgItemMessage( hDlg, IDC_ROTATE_LEFT_90, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)(HBITMAP)hBmpRotateAntiClockwise );

SendDlgItemMessage( hDlg, IDC_ROTATE_RIGHT_90, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)(HBITMAP)hBmpRotateClockwise );

Remeber that because you have to manually load the images and store them somewhere, you should release them when you close the dialog...

Share this post


Link to post
Share on other sites
You have to manually load the images in the WM_INITDIALOG message and associate them with the button as follows:

/* Load the button images */
hBmpRotateAntiClockwise = (HBITMAP)LoadImage( hInst,MAKEINTRESOURCE(IDB_ROTATE_ANTI_CLOCKWISE), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );

hBmpRotateClockwise = (HBITMAP)LoadImage( hInst, MAKEINTRESOURCE(IDB_ROTATE_CLOCKWISE), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );

/* Now attatch the bitmaps to the buttons */
SendDlgItemMessage( hDlg, IDC_ROTATE_LEFT_90, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)(HBITMAP)hBmpRotateAntiClockwise );

SendDlgItemMessage( hDlg, IDC_ROTATE_RIGHT_90, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)(HBITMAP)hBmpRotateClockwise );

Remeber that because you have to manually load the images and store them somewhere, you should release them when you close the dialog...

Share this post


Link to post
Share on other sites