开发者

What event is sent to a Windows Forms window when its button from the taskbar is clicked?

开发者 https://www.devze.com 2022-12-30 02:36 出处:网络
When the user clicks the window title/button in the taskbar, what .NET event (or Windows API message) is sent to the window?

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开发者_开发技巧


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

"D:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\spyxx.exe" 

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消