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

x
?
Solved

VC++ - problem with GetWindowRect()

Posted on 1998-06-12
4
Medium Priority
?
322 Views
Last Modified: 2008-02-01
I am trying to move an object on top of another object in a view window. I am positioning the second object based on the coordinates returned by GetWindowRect() of the first object. This works fine when the manin view is maximized, however when the view is made smaller so that scroll bars appear, the GetWindowRect() coordinates do not seem to be right. When I try to put the second object to a position of
object1rect.top (which is of CRect type) they do not match up. How can get an accurate position of the first object to determine where to put the second?
0
Comment
Question by:englm
[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
  • 3
4 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 1165747
Answer coming.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1165748
GetWindowRect returns coordinates that are relative to the top-left corner of the screen.  However, when you move a window, you specify coordinates that are relative to the top-left corner of the window's parent's client area.    The you need to convert the coordinates from screen coordinates to the parent windows client coordinates, before the move.  This is done with ScreenToClient().

Note, if the parent window is maximized, then its client area's top-left corner is almost at the screen's top-left corner.  Thus the two coordinate systems are almost aligned.  That is why you don't see the problem with a maximized parent window.  However, the problem was still there.

If you have any questions, ask.
0
 

Author Comment

by:englm
ID: 1165749
I'm not sure exactly what the two coordinate sytems are doing, but it seemed to cure my problem.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1165750
They aren't "doing" anything.  Its just the fact that the rectangle's position is measured from different points at different times.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

670 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