• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 609
  • Last Modified:

CbitmapButton on CDialogBar

Can i put a CBitmapBUtton on my CDialogBar.

Becoz i didn't derive any class from CDialogBar and all i did was create a variable of Type CDialogBar and Create() from the dialog that ive created earlier. Within the dialog ive dragged and drop several buttons and comboboxes...

Now i have no idea how to change the buttons into a CbitmapButton becoz i dunno where i shud place the AutoLoad function to load the appropriate Bitmaps?

0
lamer
Asked:
lamer
  • 3
  • 3
  • 2
1 Solution
 
AxterCommented:
1. Open your dialog via the resource editor.
2. Right-Mouse click your button.
3. Select properties from the pop-down menu.
4. The properties screen will popup.
5. Click the "Styles" tab.
6. Set the "Owner draw" and the "Bitmap" fields.
7. Click the "General" tab, and make sure the "Visible" field is set.
8. Press Ctrl-W
9. Click the Member-Variables Tab
10. Double click the ID of your button (IDC_BUTTON1) listed under the controls Ids
11. The "Add-Member Variable" form will popup.
12. In the Member-Variable-Name field, enter the name of your new control variable. (Example: m_MyButtonControl)
13. Click OK.
14. Click OK on the Class Wizard.
15. Open your Dialog.H (Header) file.
16. Find your new variable between the "AFX_DATA".  Something like "CButton       m_MyButtonControl ;"
17. Change the CButton to CBitmapButton.
18. Open your dialog CPP file.
19. On the constructor, add your LoadBitmaps function.  (Example: m_MyButtonControl.LoadBitmaps(IDB_BITMAP1,IDB_BITMAP2,IDB_BITMAP3,IDB_BITMAP4);

That's it.
0
 
AxterCommented:
I'm sorry Lamer,
I obviously gave you instructions for creating a CBitmapButton on a Dialog class, and not a CDialogBar.
I didn't realize your question was on a CDialogBar until after I submitted the comment.
0
 
lamerAuthor Commented:
Yeah, i noticed... :)

So now i am just wondering which one is easier...

Using a CToolBarCtrl to add CComboBoxes..(BitmapButtons are already supported natively) or using a CDialogBar with CBitmapButtons? if so plz do give some sample source.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
RONSLOWCommented:
Answer 1: derive your own class from CDialogBar and do the DDX_Control etc from there.

Answer 2: there is sample code out there for combo boxes in toolbars.  MSJ has code/articles (if you have MSDN) and www.codeguru.com should help you out as well.

If all you want is a bunch of buttons and a combo box, then I think using a toolbar with a combo box on it is best (you get all the nice resizing etc of tool bars).

If there is more to it, then go for a CDialogBar derived class.

Alternatively, use Rebar cotrols, which let you put whatever you like in the bars.  But they have other limitations.

Again, check out MSJ and Codeguru for examples and discussions about these issues and decide what one bets suits your particular requirements and which you like the most.

0
 
lamerAuthor Commented:
DDX_COntrol on CBItmapButton didn't
work.. i got some error message saying
that its an unsupported attempt or something..


Answer 2 is unacceptable.. i already know that..  But please do explain on Answer 1,

Thanks.
0
 
RONSLOWCommented:
Derive a class from CDialogBar.
Either use DDX_Control or explicitly subclass the bitmap button in the OnInitDialog.

If this is what you already tried, please give a more specific error message so we can see what went wrong.
0
 
AxterCommented:
lamer,
Can you post your class code.  Just the class that is creating the CDialogBar.
0
 
lamerAuthor Commented:
its ok, ive got the codes from Code guru and ive fixed the bug.

Basically what i did was extended the A CdialogBar class to CDialogBarEx

and later extended CDialogBarEx to another class. THis is to facillitate the OnInitDialog for a CDialogBar.

0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now