PDA

Click to See Complete Forum and Search --> : Get X-Y position of a control????


WarrenW
Oct 24th, 2001, 08:52 PM
I bet this is a tough question!

How can I get the X / Y coordinates of a control in a program so I can capture only that part? I have the class name and the handle and I need to capture only that part of the screen. The control can be in a different position of the program depending how the user has it setup because it is in Outlook Express.

Is there an API call I can do to get this?

Anyone have any suggestions?

Thanks!

Vlatko
Oct 25th, 2001, 07:36 AM
You can use this API:

Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) As Long

· hWnd
Identifies the window.

· lpRect
Points to a RECT structure that receives the screen coordinates of the upper-left and lower-right corners of the window.

WarrenW
Oct 25th, 2001, 08:07 AM
Thanks, works great!!!

Megatron
Oct 25th, 2001, 02:42 PM
If you want to capture the points of a child window, you would either need to use GetClientRect, or if the control actually has a separate client section, then you need to convert the coordinates (from GetWindowRect) to the client coordinates by using the ScreenToClient function.