Getting control coordinates
-
How do you get the coordinates of a control on a dialog relative to the upper-left corner of the dialog? I've tried using the GetClientRect & GetWindowRect functions of the control I want the coords for, but neither returns the right value. Any help is appreciated. Thanks. - Aaron
-
How do you get the coordinates of a control on a dialog relative to the upper-left corner of the dialog? I've tried using the GetClientRect & GetWindowRect functions of the control I want the coords for, but neither returns the right value. Any help is appreciated. Thanks. - Aaron
-
How do you get the coordinates of a control on a dialog relative to the upper-left corner of the dialog? I've tried using the GetClientRect & GetWindowRect functions of the control I want the coords for, but neither returns the right value. Any help is appreciated. Thanks. - Aaron
I got it working using GetWindowRect of the control and ScreenToClient of the dialog. Is this the best way to do it? [EDIT] Guess I should have refreshed before I posted :) Thanks for the help though [/EDIT] - Aaron
-
How do you get the coordinates of a control on a dialog relative to the upper-left corner of the dialog? I've tried using the GetClientRect & GetWindowRect functions of the control I want the coords for, but neither returns the right value. Any help is appreciated. Thanks. - Aaron
Off the top of my head. GetClientRect(): is the rectangular area that represents the area where drawing is to occur, with (0,0) representing the upper left courner of the client area within the window. GetWindowRect(): is the rectangular area that represents the area where the window is draw in screen coordinates and must be converted to client coordinates to be useful. Therefore, you need to get the screen coordinates via GetWindowRect() and then convert them to the dialog coordinates via ScreenToClient(). Now is there a better way or a function that does the needed conversion for you? I am not sure, there is one function whose usage is a bit confusing so I keep forgetting its' name and all I remeber (at the moment) is that it converts from one coordinate system to anoghter (a.k.a. client to screen or screen to client). Basicaly, it is less confusing to do it your self (with two simple function calls), than to call some function that (based on the arguments) makes the same function calls. INTP