Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

can't get correct  rect of the toolbar

Posted on 1998-03-15
1
Medium Priority
?
357 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
[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
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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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