Solved

Deriving from CToolBar

Posted on 1997-04-05
5
483 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how do i create updater to My Activex application? 3 108
deburging in oracle form 12 119
haveThree challenge 22 127
sumHeights2  challenge 7 140
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

738 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