如题,window中其他的控件的WM_TOUCH消息都去到了,但是WindowsFormsHost的没去到。有没有办法获得WindowsFormsHost里的WM_TOUCH消息?WindowsFormsHost里的鼠标消息也没得到。
我用得是:
System.IntPtr hWnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
if (!RegisterTouchWindow(hWnd, 0))
{
Debug.Print("ERROR: Could not register window for multi-touch");
}
// GetTouchInputInfo needs to be
// passed the size of the structure it will be filling.
// We get the size upfront so it can be used later.
touchInputSize = Marshal.SizeOf(new TOUCHINPUT());
/// 将窗口MainWindow与WndProc关联起来
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
if (hwndSource != null)
{
hwndSource.AddHook(new HwndSourceHook(WndProc));
}
protected virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
switch (msg)
{
case WM_TOUCH:
{
handled = DecodeTouch(wParam, lParam);
}
break;
case WM_LBUTTONDOWN:
{
System.Windows.MessageBox.Show("asdfsdfs");
}
break;
}
return IntPtr.Zero;
}