Solved

CbitmapButton on CDialogBar

Posted on 2000-04-01
8
592 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now