示例#1
0
        /// <summary>
        /// 根据Windows消息内容计算鼠标光标在屏幕中的位置
        /// </summary>
        /// <param name="intMessage">Windows消息编号</param>
        /// <param name="Hwnd">Windows消息中的窗体句柄</param>
        /// <param name="lParam">Windows消息的Param参数</param>
        /// <returns>鼠标光标在屏幕中的位置</returns>
        public static System.Drawing.Point GetMousePositionFromMessage(int intMessage, IntPtr Hwnd, uint lParam)
        {
            bool bolClient = true;

            if (// 鼠标在非客户区的按键按下消息
                (intMessage == (int)Msgs.WM_NCLBUTTONDOWN) ||
                (intMessage == (int)Msgs.WM_NCMBUTTONDOWN) ||
                (intMessage == (int)Msgs.WM_NCRBUTTONDOWN) ||
                (intMessage == (int)Msgs.WM_NCXBUTTONDOWN) ||
                // 鼠标在非客户区的按键松开消息
                (intMessage == (int)Msgs.WM_NCLBUTTONUP) ||
                (intMessage == (int)Msgs.WM_NCMBUTTONUP) ||
                (intMessage == (int)Msgs.WM_NCRBUTTONUP) ||
                (intMessage == (int)Msgs.WM_NCXBUTTONUP) ||
                // 鼠标在非客户区的移动消息
                (intMessage == (int)Msgs.WM_NCMOUSEMOVE))
            {
                bolClient = false;
            }
            NativePOINT pt = new NativePOINT();

            pt.x = (short)(lParam & 0x0000FFFFU);
            pt.y = (short)((lParam & 0xFFFF0000U) >> 16);
            if (bolClient)
            {
                ClientToScreen(Hwnd, ref pt);
            }
            return(new System.Drawing.Point(pt.x, pt.y));
        }
示例#2
0
        public static System.Drawing.Point GetMousePositionFromMSG(NativeMSG msg)
        {
            NativePOINT pt = new NativePOINT();

            pt.x = (short)((uint)msg.lParam & 0x0000FFFFU);
            pt.y = (short)(((uint)msg.lParam & 0xFFFF0000U) >> 16);
            ClientToScreen(new IntPtr(msg.hwnd), ref pt);
            return(new System.Drawing.Point(pt.x, pt.y));
        }
示例#3
0
        public static System.Drawing.Point GetMousePositionFromMSG(IntPtr hwnd, uint lParam)
        {
            NativePOINT pt = new NativePOINT();

            pt.x = (short)(lParam & 0x0000FFFFU);
            pt.y = (short)((lParam & 0xFFFF0000U) >> 16);
            ClientToScreen(hwnd, ref pt);
            return(new System.Drawing.Point(pt.x, pt.y));
        }
示例#4
0
 public static extern int WindowFromPoint(NativePOINT Point);
示例#5
0
 public static extern bool ScreenToClient(IntPtr hWnd, ref NativePOINT pt);
示例#6
0
 public static extern bool ClientToScreen(IntPtr hWnd, ref NativePOINT pt);
示例#7
0
 public static extern bool UpdateLayeredWindow(IntPtr hwnd, int hdcDst, ref NativePOINT pptDst, ref SIZE psize, int hdcSrc, ref NativePOINT pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);