У меня есть блок кода, как:WinForms эквивалент WPF WindowInteropHelper, HwndSource, HwndSourceHook
IntPtr hWnd = new WindowInteropHelper(this).Handle;
HwndSource source = HwndSource.FromHwnd(hWnd);
source.AddHook(new HwndSourceHook(WndProc));
NativeMethods.PostMessage((IntPtr)NativeMethods.HWND_BROADCAST, NativeMethods.WM_CALL, IntPtr.Zero, IntPtr.Zero);
Это было первоначально в приложении WPF. Тем не менее, мне нужно реплицировать функциональность в приложении WinForms. Кроме того, NativeMethods.PostMessage просто карты для USER32.dll PostMessage:
[DllImport("user32")]
public static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
Есть 1 к 1 экв WindowInteropHelper/HwndSource/HwndSourceHook
, что я могу использовать в своих приложениях WinForms?
Просто переопределить метод WndProc(). –