Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HWnd Message Hook in WinForms?

Tags:

c#

winforms

wpf

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

HwndSource.FromHwnd(_windowHandle).AddHook(HwndSourceHookHandler);
like image 439
Chris Avatar asked Aug 29 '11 17:08

Chris


1 Answers

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.

like image 181
Reed Copsey Avatar answered Sep 21 '22 21:09

Reed Copsey