private Point ScreenPtToClientPt(Point pt, IntPtr handle)
        {
            PI.POINTC clientPt = new PI.POINTC
            {
                x = pt.X,
                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
            {
                x = 0,
                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));
        }
Example #2
0
        public static Point ClientMouseMessageToScreenPt(Message m)
        {
            // Extract the x and y mouse position from message
            PI.POINTC clientPt = new PI.POINTC();
            clientPt.x = PI.LOWORD((int)m.LParam);
            clientPt.y = PI.HIWORD((int)m.LParam);

            // 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(m.HWnd, IntPtr.Zero, 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);
        }
Example #3
0
 internal static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, [In, Out] PI.POINTC pt, int cPoints);