I am building a C# app in .net 4.0. For some reason I can’t make this code work:
HwndSource Source;
Source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
Source.AddHook(new HwndSourceHook(Window_Proc));
Can’t seem to import the correct assembly.
Since you’re doing this inside of a Windows Forms Form class, you can just override WndProc instead of trying to use an
HwndSourceand a hook.