我正在解决一个问题(如何检测在应用程序中打开的表单)并偶然发现了一条我无法理解的 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;
}
}