/// <summary> /// 引发 FilterMessageEvent 事件 /// </summary> /// <param name="e">事件参数</param> protected virtual void OnFilterMessage(MessageFilterEventArgs e) { if (this.FilterMessageEvent != null) { this.FilterMessageEvent(this, e); } }
private void AppClickFilter_FilterMessageEvent( object sender, MessageFilterEventArgs e ) { if ( this.ExcludeControls != null && this.ProcessFun != null ) { List<IntPtr> childWindows = WindowsAPI.GetWindows( this.ExcludeControls.ToArray() ); if ( !childWindows.Contains( e.CurrentMessage.HWnd ) ) { this.ProcessFun(); } } }
private void MouseWheelFilter_FilterMessageEvent( object sender, MessageFilterEventArgs e ) { if ( this.SendToControls != null ) { foreach ( Control c in this.SendToControls ) { WindowsAPI.SendMessage( c.Handle, e.CurrentMessage.Msg, e.CurrentMessage.WParam, e.CurrentMessage.LParam ); } e.StopMessage = false; } }
private void MouseWheelFilter_FilterMessageEvent(object sender, MessageFilterEventArgs e) { if (this.SendToControls != null) { foreach (Control c in this.SendToControls) { WindowsAPI.SendMessage(c.Handle, e.CurrentMessage.Msg, e.CurrentMessage.WParam, e.CurrentMessage.LParam); } e.StopMessage = false; } }
private void AppClickFilter_FilterMessageEvent(object sender, MessageFilterEventArgs e) { if (this.ExcludeControls != null && this.ProcessFun != null) { List <IntPtr> childWindows = WindowsAPI.GetWindows(this.ExcludeControls.ToArray()); if (!childWindows.Contains(e.CurrentMessage.HWnd)) { this.ProcessFun(); } } }
/// <summary> /// 实现 IMessageFilter 接口, 当匹配到消息时引发 FilterMessageEvent 事件. /// </summary> /// <param name="m"></param> /// <returns></returns> public virtual bool PreFilterMessage(ref Message m) { bool result = false; if (this.Enable) { //是否应过滤消息 bool isOk = true; if (this.FilterMessages != null && this.FilterMessages.Count > 0) { if (!this.FilterMessages.Contains(m.Msg)) { isOk = false; } } if (this.TargetHandles != null && this.TargetHandles.Count > 0) { if (!this.TargetHandles.Contains(m.HWnd)) { isOk = false; } } if (isOk) { MessageFilterEventArgs e = new MessageFilterEventArgs(); e.CurrentMessage = m; e.StopMessage = result; this.OnFilterMessage(e); result = e.StopMessage; } } return(result); }
/// <summary> /// 引发 FilterMessageEvent 事件 /// </summary> /// <param name="e">事件参数</param> protected virtual void OnFilterMessage( MessageFilterEventArgs e ) { if ( this.FilterMessageEvent != null ) { this.FilterMessageEvent( this, e ); } }
/// <summary> /// 实现 IMessageFilter 接口, 当匹配到消息时引发 FilterMessageEvent 事件. /// </summary> /// <param name="m"></param> /// <returns></returns> public virtual bool PreFilterMessage( ref Message m ) { bool result = false; if ( this.Enable ) { //是否应过滤消息 bool isOk = true; if ( this.FilterMessages != null && this.FilterMessages.Count > 0 ) { if ( !this.FilterMessages.Contains( m.Msg ) ) { isOk = false; } } if ( this.TargetHandles != null && this.TargetHandles.Count > 0 ) { if ( !this.TargetHandles.Contains( m.HWnd ) ) { isOk = false; } } if ( isOk ) { MessageFilterEventArgs e = new MessageFilterEventArgs(); e.CurrentMessage = m; e.StopMessage = result; this.OnFilterMessage( e ); result = e.StopMessage; } } return result; }