【发布时间】:2015-09-21 07:57:33
【问题描述】:
我正在解决一个问题 (How to Detect a form open inside the application),偶然发现一条我无法理解的 Windows 消息:0xC052。
这是我在表单打开时在 MessageFilter 中收到的第一条消息。但由于我没有找到任何参考资料,我不想依赖这样的假设,即消息告诉我表单已打开是可靠的。
编辑:添加代码
Application.AddMessageFilter(new MessageFilterImpl());
class MessageFilterImpl : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
Control wnd = Form.FromHandle(m.HWnd);
if (wnd is Form)
knownForms.Add((Form)wnd); //m.Msg is 0xC052
return false;
}
}
【问题讨论】:
-
这听起来像是从您安装的另一个应用程序广播的内容 - 这不是标准消息。无论如何,我认为您正在寻找的是
Load事件。 -
谢谢。但是要向
Load-event 添加事件处理程序,我首先需要知道form,这是最初的问题。 -
它可以是任何字符的Unicode。
-
为什么unicode-character应该是message-loop中的message-code?span>
标签: .net winforms message-loop