Главная страница | назад

Article #17035: MapDialogRect vs. GetWindowRect

 Question and Answer Database
FAQ2035C.txt MapDialogRect vs. GetWindowRect
Category :Windows API
Platform :All
Product :C++Builder ALL
I've loaded a dialog from a resource file, and i've used
MapDialogRect to calculate its screen position. The
coordinates returned by MapDiagRect, however, have no
apparent relationship to the coordinates returned by
GetWindowRect. Why?
There are actualy two problems inherent in what you are
trying to do. First off, GetWindowRect returns the rectangle
of the external bounding frame of the window --- which is to
say, the title bar and frame are within the rectangle ---
while MapDialogRect returns the rectangle for the client
area. (That can be demonstrated by calling GetClientRect on
the area and comparing its values to the values returned by
the two previous functions.)
The other problem is this: while GetWindowRect returns a
rectangle whose coordinates are screencoordinates, that is,
they are relative to the upper left hand corner of your
screen, MapDialogRect returns a rectangle whose coordinates
are relative to the client area of the parent window. Thus,
while the rectangles actually describe the same window, they
are applied to different coordinate schemes, and so look
different upoon inspection.
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99