public static WindowsMessage GetMessage(IntPtr window, uint filterMin, uint filterMax)
        {
            MSG nativeMessage;

            WindowsMessage.GetMessage(out nativeMessage, window, filterMin, filterMax);
            return(new WindowsMessage(nativeMessage));
        }
        public WindowsMessage Translate()
        {
            MSG message = this.NativeMessage;

            WindowsMessage.TranslateMessage(ref message);
            return(new WindowsMessage(message));
        }
        public IntPtr Send(IntPtr window)
        {
            IntPtr result = WindowsMessage.SendMessage(window, this.NativeMessage.message, this.NativeMessage.wParam,
                                                       this.NativeMessage.lParam);

            return(result);
        }
        public IntPtr Dispatch()
        {
            MSG    message = this.NativeMessage;
            IntPtr result  = WindowsMessage.DispatchMessage(ref message);

            return(result);
        }
        public static WindowsMessage?PeekMessage(bool remove, bool noYield, IntPtr window, uint filterMin,
                                                 uint filterMax)
        {
            uint flags = (remove ? WindowsMessage.PM_REMOVE : WindowsMessage.PM_NOREMOVE) &
                         (noYield ? WindowsMessage.PM_NOYIELD : 0);

            MSG nativeMessage;

            if (!WindowsMessage.PeekMessage(out nativeMessage, window, filterMin, filterMax, flags))
            {
                return(null);
            }

            return(new WindowsMessage(nativeMessage));
        }
Beispiel #6
0
        public void Run()
        {
            try
            {
                lock (this.SyncRoot)
                {
                    this.VerifyNotRunning();

                    this.Thread           = Thread.CurrentThread;
                    this.ThreadId         = WindowsMessage.GetCurrentThreadId();
                    this.Queue            = new Hashtable();
                    this.LastInvokeHandle = 0;
                    this.ShutdownMode     = WindowsMessageLoopShutdownMode.None;
                }

                while (true)
                {
                    WindowsMessage message = WindowsMessage.GetMessage();

                    message = message.Translate();
                    message.Dispatch();

                    //TODO: Events etc.
                    //TODO: Observe shutdown mode
                }
            }
            finally
            {
                lock (this.SyncRoot)
                {
                    this.Queue?.Clear();

                    this.Thread           = null;
                    this.ThreadId         = 0;
                    this.Queue            = null;
                    this.LastInvokeHandle = 0;
                }
            }
        }
 internal static uint GetCurrentThreadId()
 {
     return(WindowsMessage.GetCurrentThreadIdNative());
 }
 public static WindowsMessage?PeekMessage(bool remove, bool noYield, IntPtr window)
 {
     return(WindowsMessage.PeekMessage(remove, noYield, window, 0, 0));
 }
 public static WindowsMessage?PeekMessage(bool remove, bool noYield)
 {
     return(WindowsMessage.PeekMessage(remove, noYield, IntPtr.Zero));
 }
 public static WindowsMessage GetMessage(IntPtr window)
 {
     return(WindowsMessage.GetMessage(window, 0, 0));
 }
 public static WindowsMessage GetMessage()
 {
     return(WindowsMessage.GetMessage(IntPtr.Zero));
 }
 internal void Post(uint nativeThreadId)
 {
     WindowsMessage.PostThreadMessage(nativeThreadId, this.NativeMessage.message, this.NativeMessage.wParam,
                                      this.NativeMessage.lParam);
 }
 public void PostQuit(int exitCode)
 {
     WindowsMessage.PostQuitMessage(exitCode);
 }
 public void Post(IntPtr window)
 {
     WindowsMessage.PostMessage(window, this.NativeMessage.message, this.NativeMessage.wParam,
                                this.NativeMessage.lParam);
 }