Solved

Deriving from CToolBar

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

821 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