单击任务栏上的 Windows 窗体窗口按钮时,将向 Windows 窗体窗口发送什么事件?
当用户单击任务栏中的窗口标题/按钮时,什么 .NET 事件(或 Windows API 消息)会发送到窗口?
我正在使用 C#/.NET 2.0/Windows 窗体。
谢谢
When the user clicks the window title/button in the taskbar, what .NET event (or Windows API message) is sent to the window?
I'm using C#/.NET 2.0/Windows Forms.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要发现在不同点发送到窗口的消息,您应该考虑使用 Microsoft Spy++。在我的机器上,它位于以下路径
注意我使用的是 64 位操作系统,因此是 (x86)。
消息的类型和数量相当大,而且我确信 XP 和 Windows 7 等操作系统版本之间略有不同。但是关键事件/消息可能会保持相当不变。
WM_ACTIVATE(激活和停用时)
WM_WINDOWPOSCHANGING
WM_WINDOWPOSCHANGED
。
另一个不错的工具是 ManagedSpy,但我没有在 XP 以外的任何平台上尝试过它,它似乎不能在 Windows 7 64 位上运行,但我还没有做太多调查(还!)
http://msdn.microsoft.com/en-us/magazine/cc163617。 ASPX
To discover the messages that are send to a window at various points you should consider using Microsoft Spy++. On my machine it is located at the following path
Note I am using 64bit OS hence the (x86).
The type and number of messages is quite big and I am sure varies slightly between OS versions like XP and Windows 7. However the key events/mesages would probably remain pretty constant.
WM_ACTIVATE (When activating and deactivating)
WM_WINDOWPOSCHANGING
WM_WINDOWPOSCHANGED
etc.
Another good tool is ManagedSpy, but I have not tried it on anything other than XP, it does not seem to run on Windows 7 64bit, but I have not done much investigation (Yet!).
http://msdn.microsoft.com/en-us/magazine/cc163617.aspx
激活和停用事件通常在您单击任务栏按钮时发生,但并非总是如此。当您单击某个窗口或单击另一个窗口时,也会发生这种情况。
我发现它们没有发生的一次是当窗口处于活动状态时,您单击任务栏按钮以最小化应用程序,并且停用和激活都会发生。然后,当您单击任务栏按钮恢复窗口时,不会触发 Activated 事件。这对我来说似乎很奇怪。
The Activated and Deactivate events usually occur when you click on the taskbar button, but not always. They also occur when you just click on the window or click away to another window.
The one time I found that they don't occur is when the window is active, you click on the taskbar button to minimize the app, and Deactivate occurs as well as Activated. Then when you click on the taskbar button to restore the window, the Activated event doesn't fire. This seems weird to me.