Solved

can't get correct  rect of the toolbar

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maxBlock challenge 30 142
VBA "SendKeys" Syntax for Multiple Keystrokes 7 117
ffmpeg - "rtsp://...... Operation not permitted" 4 86
Change to event 1 119
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 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