开发者

HWnd Message Hook in WinForms?

What is the WinForms equivalent to the following line of WPF code?

HwndSource.FromHwnd(_windowHandle).AddHook(HwndSourceHookH开发者_Go百科andler);


In WinForms, you'd typically override WndProc in the control/Form in question. Since every control is effectively a HWND, you don't need the HwndSource style of hooking.


If you want to setup a Hook in C#, you can follow the guidelines in How to set a Windows hook in Visual C# .NET.


Inside your own process, you can use the Application.AddMessageFilter method to listen to specific events before they are dispatched anywhere. This doesn't work between processes.

I found this while searching for an answer to one of my questions about handling of mouse events between parent and child controls.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜