954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Setting bitmap on button

Hello. I'm creating a program with dialog editor. How can i set bitmap on button? I set bitmap at properties to True. I tried to search on google but i could only find how to set bitmap on button created with CButton.
Thank you

fire_
Junior Poster in Training
57 posts since Aug 2010
Reputation Points: 10
Solved Threads: 1
 

Assuming this is on Windows, you can load the bitmap with LoadBitmap()/LoadImage(), and then set it using the BM_SETIMAGE Message .

The button needs the BS_BITMAP style bit set, but I believe your dialog editor takes care of that.

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

Can you give me an example please? Because i didn't really undestood :(
By the way i'm using MFC.

fire_
Junior Poster in Training
57 posts since Aug 2010
Reputation Points: 10
Solved Threads: 1
 

MFC has CBitmapButton class which probably does what you are looking for.

If you don't have the Visual Studio's CTRLTEST Sample installed, you can download it from here . Though depending on which Visual Studio version you have, the downloaded code may need some tweaking in order to compile. Anyway, you need to look into the bbutton.cpp file to get an idea how CBitmapButton is used.

Also, you might search for "CBitmapButton tutorials".

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

This class is for creating new button, but i'm creating window with dialog editor so i can't use this class to create new button on dialog...

fire_
Junior Poster in Training
57 posts since Aug 2010
Reputation Points: 10
Solved Threads: 1
 

Look into the sample's .rc file, especially the three dialog resources; IDM_TEST_BITMAP_BUTTON1, IDM_TEST_BITMAP_BUTTON2 and IDM_TEST_BITMAP_BUTTON3. These are used in conjunction with the CBitmapButtons, in other words, it's pretty much about what you are doing with your dialog editor now.

This is not a simple topic, so take some time to try to understand how it works.

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: