Solved

can't get correct  rect of the toolbar

Posted on 1998-03-15
1
285 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
iSeries DB2 Query 2 98
dog bark java program 15 120
child constructor and parent constructor, overriding and overloading 6 93
mapAB Challlenge 35 173
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: 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…
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.

756 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