Solved

can't get correct  rect of the toolbar

Posted on 1998-03-15
1
280 Views
Last Modified: 2013-11-19
I want to position a button at the extreme right edge of the toolbar,
In main frame on create i create the toolbar and the buttons,
 in MainFrame::onCreate()
m_toolbar.GetClientRect returns me width and height of 0. Then i tried the Mainframe.getwindowrect which gives me less than the correct values(incidentally the keep changing each time),Could any body figure out the flaw in my pprocah, or thera a problem with MFC?
How can i get the actual(correct) size of the toolbar
0
Comment
Question by:sreek2
1 Comment
 
LVL 11

Accepted Solution

by:
mikeblas earned 50 total points
ID: 1316998
Any CControlBar-derived object (like CToolbar) always creates itself with a zero size.  Then, it negotiates with the view, the frame and the docking sites to find a size.

In fact, during the lifetime of the bar, it may change shape and orientation several times--try undocking a toolbar and dragging it around!

The bar will only have a valid rect after CalcLayout() has been called at least once. That happens in response to several situations: the frame being initially created, the frame changing size, the user docking or undocking any bar from or to the frame, or the user moving this particular bar.

Adding an extra control to a toolbar from the outside is going to be dicey at best. You should derive your own class from the toolbar. Then, account for your new control's size when CalcLayout() is called. When the bar changes size, make sure you move your button to an appropriate spot depending on the orientation and layout of the control.

.B ekiM

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 94
how do i create updater to My Activex application? 3 74
Expand data scrubbing tool 13 31
only14 challenge 19 64
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 …
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

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