如何覆盖Winforms中的消息循环

如何覆盖Winforms中的消息循环

本文介绍了如何覆盖Winforms中的消息循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我遇到了需要做一些自定义消息过滤的情况.
不幸的是,我需要的功能比IMessageFilter系统提供的功能要多,或者需要覆盖Form的wndproc( )方法.
我需要的是能够在处理消息之前和之后运行代码,并可以选择删除选定的消息.据我了解,

IMessageFilter系统仅允许筛选出选定的消息
(处理完之后无法运行代码)





窗体的wndproc方法仅看到发往该窗体的消息. (我需要处理整个应用程序的所有消息)

在非托管应用程序中,在Visual C ++中说这将是实现自己的getmessage/dispatchmessage循环的简单方法.在dotnet框架中,实际的消息循环是用本机代码实现的,并且程序员无法访问.

有人知道解决方案吗?

请问,
> Felix

Hi All,
I have a situation where I need to do some custom message filtering.
Unfortunately I need more functionality than provided by the
IMessageFilter system or by overriding a Form''s wndproc() method.
What I need is to be able to run code before and after a message is
processed and optionally drop selected messages.

As I understand it:

The IMessageFilter system only allows filtering out selected messages
(can''t run code after they have been processed)

A Form''s wndproc method only sees messages destined for that form. (I
need to handle all messages for the entire application)

In an unmanaged application say in visual c++ it would be a simple
matter of implementing ones own getmessage/dispatchmessage loop. In
the dotnet framework the actual message loop is implemented in native
code and is inaccessible to the programmer.

Does anyone know a solution for this?

Regards,
Felix

推荐答案


在Jeff Richter上搜索或形成消息拦截,您可能会更快到达那里.

Search on Jeff Richter or forms message intercept and you might get there more quickly.

对不起,我在这里只有C

Sorry all I have here is C

Best of Luck

Best of Luck



这篇关于如何覆盖Winforms中的消息循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 01:01