加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

WPF等效于Application.AddMessageFilter(Windows窗体)

发布时间:2020-12-14 02:25:36 所属栏目:Windows 来源:网络整理
导读:我在WinForms应用程序中使用Application.AddMessageFilter()(使用非托管代码时). 现在我正在切换到WPF,但无法找到此功能. 请告知可以找到或实施的地方. 解决方法 在WPF中,您可以使用ComponentDispatcher.ThreadFilterMessage事件. ComponentDispatcher.Threa
我在WinForms应用程序中使用Application.AddMessageFilter()(使用非托管代码时).

现在我正在切换到WPF,但无法找到此功能.

请告知可以找到或实施的地方.

解决方法

在WPF中,您可以使用ComponentDispatcher.ThreadFilterMessage事件.

ComponentDispatcher.ThreadFilterMessage += ComponentDispatcher_ThreadFilterMessage;
private void ComponentDispatcher_ThreadFilterMessage(ref MSG msg,ref bool handled)
{
     if (msg.message == 513)//MOUSE_LEFTBUTTON_DOWN
     {
         //todo
     }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读