Solved

RECT Help:

Posted on 2000-04-17
7
314 Views
Last Modified: 2010-04-02
I would like to know how I could find out the position where my dialog starts, NOT INCLUDING THE MENU part.  When my application window resizes, I also resize a text box, however when I subtract to calculate the size of the text box, I miscalculate the size if the menu takes up multiple lines, or the user has changed the font / size of the menus.  Please show me how I could find where the rect of my window starts not including the Menu part in C++.
0
Comment
Question by:Toad224
  • 5
7 Comments
 
LVL 3

Expert Comment

by:mnewton022700
ID: 2724707
Use CWnd::GetClientRect and CWnd::ClientToScreen.

eg.

CRect clientRect;
this->GetClientRect(clientRect);
this->ClientToScreen(clientRect);
0
 
LVL 2

Accepted Solution

by:
xLs earned 832 total points
ID: 2724713
use GetClientRect();
0
 
LVL 3

Expert Comment

by:mnewton022700
ID: 2724714
Sorry, I've got MFC on the brain. The non-MFC way would be:

RECT rect;

::GetClientRect(hWnd, &rect);
::ClientToScreen(hWnd, &rect);

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:mnewton022700
ID: 2724722
You'll need to convert the client coordinates to screen coordinates to work out the actual position of the window.
0
 
LVL 3

Expert Comment

by:mnewton022700
ID: 2724727
You need the ClientToScreen call to convert the client coordinates to screen coordinates so that you have the actual position of the window.

0
 
LVL 1

Author Comment

by:Toad224
ID: 2724736
Why didn't you make yours an answer, mnewton?
0
 
LVL 3

Expert Comment

by:mnewton022700
ID: 2724754
You're right, I should have. I generally don't submit answers because it restricts other people from making other constructive comments (sort of anyway). But in this case I should have made my comment an answer.

If you want to you could still decline xLs and accept my comment. Either way,
is fine with me.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

910 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