private Point ScreenPtToClientPt(Point pt, IntPtr handle) { PI.POINTC clientPt = new PI.POINTC(); clientPt.x = pt.X; clientPt.y = pt.Y; // Negative positions are in the range 32767 -> 65535, // so convert to actual int values for the negative positions if (clientPt.x >= 32767) { clientPt.x = (clientPt.x - 65536); } if (clientPt.y >= 32767) { clientPt.y = (clientPt.y - 65536); } // Convert a 0,0 point from client to screen to find offsetting PI.POINTC zeroPIPt = new PI.POINTC(); zeroPIPt.x = 0; zeroPIPt.y = 0; PI.MapWindowPoints(IntPtr.Zero, handle, zeroPIPt, 1); // Adjust the client coordinate by the offset to get to screen clientPt.x += zeroPIPt.x; clientPt.y += zeroPIPt.y; // Return as a managed point type return(new Point(clientPt.x, clientPt.y)); }
internal static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, [In, Out] PI.POINTC pt, int cPoints);