Exemple #1
0
        /// <summary>
        /// 清空指定窗体消息队列中的所有的消息
        /// </summary>
        /// <returns>删除的消息个数</returns>
        public static int ClearMessage(IntPtr hwnd)
        {
            int result = 0;

            while (true)
            {
                NativeMSG msg = new NativeMSG();
                //if (NativeGetMessage(ref msg, hwnd, 0, 0))
                //{
                //    result++;
                //}
                //else
                //{
                //    break;
                //}
                if (NativePeekMessage(ref msg, hwnd, 0, 0, 0xffffff))
                {
                    if (msg.message == 0)
                    {
                        break;
                    }
                    result++;
                }
                else
                {
                    break;
                }
            }//while
            return(result);
        }
Exemple #2
0
 private Win32Message(NativeMSG msg)
 {
     _HWnd   = new IntPtr(msg.hwnd);
     _LParam = new IntPtr(msg.lParam);
     _Msg    = msg.message;
     _WParam = new IntPtr(msg.wParam);
 }
Exemple #3
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));
        }
Exemple #4
0
        /// <summary>
        /// 从消息队列中获得一个消息,但不从消息队列中删除该消息
        /// </summary>
        /// <returns>获得的消息对象</returns>
        public static Win32Message Peek()
        {
            NativeMSG msg = new NativeMSG();

            if (NativePeekMessage(ref msg, IntPtr.Zero, 0, 0, 0))
            {
                return(new Win32Message(msg));
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
        /// <summary>
        /// 从消息队列中获得一个消息对象,并从消息队列中删除这个消息
        /// </summary>
        /// <returns>获得的消息对象</returns>
        public static Win32Message GetMessage()
        {
            NativeMSG msg = new NativeMSG();

            if (NativeGetMessage(ref msg, IntPtr.Zero, 0, 0))
            {
                Win32Message msg2 = new Win32Message(msg);
                return(msg2);
            }
            else
            {
                return(null);
            }
        }
Exemple #6
0
 [DllImport("user32", CharSet = CharSet.Ansi)]      //ANSI
 public static extern int DispatchMessageA(ref NativeMSG msg);
Exemple #7
0
 [DllImport("user32")]         //ANSI
 public static extern bool PeekMessageA(out NativeMSG lpMsg, int hWnd, uint wMsgFilterMin, uint wMsgFilterMax, PeekMessageFlags wRemoveMsg);
Exemple #8
0
 [DllImport("user32")]         //ANSI
 public static extern int GetMessageA(out NativeMSG msg, int hwnd, int minFilter, int maxFilter);
Exemple #9
0
 public static extern bool PeekMessage(ref NativeMSG msg, IntPtr hWnd, uint wFilterMin, uint wFilterMax, uint wFlag);
Exemple #10
0
 public static extern bool GetMessage(ref NativeMSG msg, IntPtr hWnd, uint wFilterMin, uint wFilterMax);
Exemple #11
0
 public static extern bool DispatchMessage(ref NativeMSG msg);
Exemple #12
0
 public static extern bool TranslateMessage(ref NativeMSG msg);
Exemple #13
0
 private static extern bool NativePeekMessage(ref NativeMSG msg, IntPtr hWnd, uint wFilterMin, uint wFilterMax, uint wFlag);
Exemple #14
0
 private static extern bool NativeGetMessage(ref NativeMSG msg, IntPtr hWnd, uint wFilterMin, uint wFilterMax);