Solved

Deriving from CToolBar

Posted on 1997-04-05
5
493 Views
Last Modified: 2013-11-20


I have the need for a CToolBar derived toolbar that contains no bitmapped buttons. I want it to contain only Combo boxes (5 in total). There is a sample called DOCTOOL (from VC 4.2) that comes close to what I want. It derives from CToolBar then uses the ability to resize the ID_SEPARATOR sections of the toolbar to give the required amount of space for a combo box control.

However an EditButtons Array consisting of only ID_SEPARATORs does not allow CalcDynamicLayout to operate correctly thus loosing the advantages of deriving from CToolBar.

Has Anyone got any suggestions ? Or sample code ?



 

0
Comment
Question by:josephine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

by:josephine
ID: 1300867
Adjusted points to 127
0
 

Expert Comment

by:JohnWeidner
ID: 1300868
Maybe you will have to override the CToolbar::CalcDynamicLayout function which you have modified to work with only separators.
0
 

Accepted Solution

by:
sem040797 earned 120 total points
ID: 1300869
I would derive from CDialogBar instead. This gives you the advantage of being able to process your combo boxes just like in a modeless dialog plus gives you all the support for for the normal docking behaviors of toolbars.

Create a new dialog making its size 20 dialog units high to correspond to a normal toolbar size. Add your combo boxes. In Visual C++ 4.2, class wizard doesn't directly support CDialogBar, but I used CDialog as a base class to get my variables and messages set up then edited the code to change the derivation to CDialogBar. Be aware there is no OnInitDialog with a CDialogBar derived class. Override the Create function instead.


0
 

Author Comment

by:josephine
ID: 1300870
Sem,

I have already tried deriveing from CDialogBar. My problem with that is that I cannot specify the dimensions of the dialog in pixels but only in dialog units. Making the dialog a standard 20 pixels high is impossible because I cannot draw it in pixels. If you can tell me how to set the dialog hieght at 20 pixels high and position and size the controls in pixels the points are yours.

Regards Josephine
0
 

Expert Comment

by:sem040797
ID: 1300871
I'm a little unclear as to why you have to draw it. When you create a dialog bar, yor just refer to the resource ID of your dialog. The framework takes care of drawing it. Your controls are positioned using the resource editor. I merely sized the dialog so that when it was docked it didn't change the size of the toolbar, then positioned the controls where I wanted them.

If you have to move controls arround because you are resizing the dialog bar, check out article Q143255 How to Make a Resizable Dialog Bar. Basically you derive a new class from CDialogBar and override the CalcDynamicLayout and CalcFixedLayout functions. Samples are included in the article. I've also overridden the OnSize function for a CFormView dialog(with a resizable border) and used MoveWindow to reposition controls, however I've not tried this on a CDialogBar derived class.

If you really need to translate between dialog units and pixels, refer to the help on GetDialogBaseUnits(). This assumes you are using the system font for your dialog. If not, see article Q145994: How to Calculate Dialog Units When Not Using the System Font. These articles include sample code.


0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Suggested Courses

622 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