Solved

can't get correct  rect of the toolbar

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 61
deburging in oracle form 12 99
zeroMAx challenge 20 100
noX challenge 17 115
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

776 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