public static Point GetCoordinateRelativeToWindow(IntPtr hWnd) { Structs.Rect rect = default(Structs.Rect); WinAPI.GetWindowRect(hWnd, out rect); Point position = Cursor.Position; int x = position.X; position = Cursor.Position; int y = position.Y; return(new Point(x - rect.X, y - rect.Y)); }
public static Point ConvertToWindowCoordinates(IntPtr hWnd, int x, int y) { Structs.Rect rect = default(Structs.Rect); WinAPI.GetWindowRect(hWnd, out rect); return(new Point(rect.X + x, rect.Y + y)); }
public static Rectangle GetDimensions(IntPtr hWnd) { Structs.Rect rect = default(Structs.Rect); WinAPI.GetWindowRect(hWnd, out rect); return(new Rectangle(rect.X, rect.Y, rect.Width, rect.Height)); }
internal static extern bool GetWindowRect(IntPtr hWnd, out Structs.Rect lpRect);