Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Beginner Programmer : Coordinates Conversion Issues : Pls Help

Status
Not open for further replies.

cdgios

Technical User
Jul 17, 2002
40
US
Hi I am creating an application in which a dialog box displays the contents of registers of some device in the binary format. I have ctreated some of the child window controls (edit controls) via the resource editor in Visual C++. And and I am trying to create a few more at run time (when processing the WM_INITDIALOG message). At run time, when i use the function GetWindowRect() function to get the position of an edit control that i created using the resource editor, i get values different than what i see in the resource file (.RC file). For example, the x and y coordinates of an edit control in the .RC file is (50, 42). The x & y coordinates for the same control when i use the function getWindowRect are (163, 221). I figure that the units must be different? I want to know what units are being used in both cases and what the convesion factor should be if I am creating more edit controls at run time that need to be aligned with the already created control through the resource editor.

Thankyou very much for your help.

Best Regards
Chandra
 
As far as i know, the coordinates in RC are relative to the upper left corner of the resource (the window).
The getWindowRect coordinates in contrast are the coordiantes from the upper left corner of the screen. So, if you move the window, the RC coordinates stay the same, but the getWindowRect coordinates change.
All the coordinates should be given in pixels.
 
Oh, i forgot:
If i'm right, you can easily convert the getWindowRect coordinates to the RC coordinates by subtracting the getWindowRect coordinates of your window. And vice versa...
 
Wouldn't it be easier to call ScreenToClient/ClientToScreen ?

--- markus
 
Ahm, yes. McMerfy is right. From this you can see, how often i've done this ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top