protected override void OnClosed(EventArgs e) { if (EnableMessageBypass) { MessageFilterHook.RemoveMessageFilter(this.Handle, this); } }
public static void ClearMessageFilter() { if (m_filter != null) { MessageFilterHook.RemoveMessageFilter(m_filterWindow, m_filter); m_filter = null; m_filterWindow = IntPtr.Zero; } }
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); } }
/// <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; }
/// <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); }
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); }
protected override void OnClosed(EventArgs e) { MessageFilterHook.RemoveMessageFilter(base.Handle, this); }