Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CbitmapButton on CDialogBar

Posted on 2000-04-01
8
Medium Priority
?
602 Views
Last Modified: 2013-11-20
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
Comment
Question by:lamer
  • 3
  • 3
  • 2
8 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 2677578
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
 
LVL 30

Expert Comment

by:Axter
ID: 2677586
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
 

Author Comment

by:lamer
ID: 2678505
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:RONSLOW
ID: 2678603
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
 

Author Comment

by:lamer
ID: 2799042
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
 
LVL 10

Accepted Solution

by:
RONSLOW earned 300 total points
ID: 2803304
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
 
LVL 30

Expert Comment

by:Axter
ID: 2804417
lamer,
Can you post your class code.  Just the class that is creating the CDialogBar.
0
 

Author Comment

by:lamer
ID: 2839947
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Loops Section Overview
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question