public HomeWindowNew()
{
InitializeComponent();
SourceInitialized += HandleInitialized;
}
private void HandleInitialized(object sender, EventArgs e)
{
IntPtr wptr = new WindowInteropHelper(this).Handle;
HwndSource hs = HwndSource.FromHwnd(wptr);
hs.AddHook(new HwndSourceHook(WpfHandleWinowMsg));
}
private IntPtr WpfHandleWinowMsg(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
Console.WriteLine("00000" + msg);
switch (msg)
{
case 1:
break;
case 2:
break;
default:
break;
}
return IntPtr.Zero;
}