110,499
社区成员
发帖
与我相关
我的任务
分享
private const int WM_MOUSEMOVE = 0x200;
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == WM_MOUSEMOVE)
{
//在这里添加鼠标移动的响应
handled = true;
}
return (new IntPtr(0));
}
//窗口Loaded事件响应
private void Window_Loaded(object sender, RoutedEventArgs e)
{
IntPtr hwnd = new WindowInteropHelper(this).Handle;
HwndSource hs = HwndSource.FromHwnd(hwnd);
hs.AddHook(new HwndSourceHook(WndProc));
}