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

Recommended Answers

All 5 Replies

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.

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

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".

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...

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.