Exemplo n.º 1
0
 protected override void OnClosed(EventArgs e)
 {
     if (EnableMessageBypass)
     {
         MessageFilterHook.RemoveMessageFilter(this.Handle, this);
     }
 }
Exemplo n.º 2
0
 public static void ClearMessageFilter()
 {
     if (m_filter != null)
     {
         MessageFilterHook.RemoveMessageFilter(m_filterWindow, m_filter);
         m_filter       = null;
         m_filterWindow = IntPtr.Zero;
     }
 }
Exemplo n.º 3
0
        public static void ReleaseKeyboard(Game game)
        {
            RawInputMessageFilter filter;
            IntPtr hWnd = game.Window.Handle;

            if (filterCache.TryGetValue(hWnd, out filter))
            {
                MessageFilterHook.RemoveMessageFilter(hWnd, filter);
                filterCache.Remove(hWnd);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///   Stops processing the raw input messages received by the application.
        /// </summary>
        /// <remarks>
        ///   Call this function to stop filtering and processing raw input messages through the message pump of the target window as
        ///   previously specified by a call to <see cref="StartProcessingMessages"/>.
        ///   <para/>
        ///   This function removes any <see cref="IMessageFilter"/> previosly installed.
        /// </remarks>
        public static void StopProcessingMessages()
        {
            if (rawInputMessageFilter is null)
            {
                return;
            }

            Application.RemoveMessageFilter(rawInputMessageFilter);
            MessageFilterHook.RemoveMessageFilter(targetWindowHandle, rawInputMessageFilter);

            rawInputMessageFilter = null;
            targetWindowHandle    = default;
        }
Exemplo n.º 5
0
            /// <summary>
            /// Private rendering loop
            /// </summary>
            public void Run(RenderCallback renderCallback)
            {
                // Show the form
                _form.Show();

                // Main rendering loop);
                while (_isAlive)
                {
                    if (UseCustomDoEvents)
                    {
                        // Previous code not compatible with Application.AddMessageFilter but faster then DoEvents
                        Win32Native.NativeMessage msg;
                        while (Win32Native.PeekMessage(out msg, _windowHandle, 0, 0, 0) != 0)
                        {
                            if (Win32Native.GetMessage(out msg, _windowHandle, 0, 0) == -1)
                            {
                                throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture,
                                                                                  "An error happened in rendering loop while processing windows messages. Error: {0}",
                                                                                  Marshal.GetLastWin32Error()));
                            }

                            Win32Native.TranslateMessage(ref msg);
                            Win32Native.DispatchMessage(ref msg);
                        }
                    }
                    else
                    {
                        // Revert back to Application.DoEvents in order to support Application.AddMessageFilter
                        // Seems that DoEvents is compatible with Mono unlike Application.Run that was not running
                        // correctly.
                        Application.DoEvents();
                    }
                    if (_isAlive)
                    {
                        renderCallback();
                    }
                }

                _form.Disposed -= _form_Disposed;

                MessageFilterHook.RemoveMessageFilter(_windowHandle, this);
            }
Exemplo n.º 6
0
 public void Run(RenderLoop.RenderCallback renderCallback)
 {
     this._form.Show();
     while (this._isAlive)
     {
         if (RenderLoop.UseCustomDoEvents)
         {
             Win32Native.NativeMessage lpMsg;
             while (Win32Native.PeekMessage(out lpMsg, this._windowHandle, 0, 0, 0) != 0)
             {
                 if (Win32Native.GetMessage(out lpMsg, this._windowHandle, 0, 0) == -1)
                 {
                     throw new InvalidOperationException(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "An error happened in rendering loop while processing windows messages. Error: {0}", new object[1]
                     {
                         (object)Marshal.GetLastWin32Error()
                     }));
                 }
                 else
                 {
                     Win32Native.TranslateMessage(ref lpMsg);
                     Win32Native.DispatchMessage(ref lpMsg);
                 }
             }
         }
         else
         {
             Application.DoEvents();
         }
         if (this._isAlive)
         {
             renderCallback();
         }
     }
     this._form.Disposed -= new EventHandler(this._form_Disposed);
     MessageFilterHook.RemoveMessageFilter(this._windowHandle, (IMessageFilter)this);
 }
Exemplo n.º 7
0
 protected override void OnClosed(EventArgs e)
 {
     MessageFilterHook.RemoveMessageFilter(base.Handle, this);
 }