none
不能获取window中WindowsFormsHost里activeX控件的WM_TOUCH消息 RRS feed

  • 问题

  • 如题,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;
            }

    2011年10月11日 14:43

答案

  • 你好,

    相应的消息应该是在WindowsFormsHost的Child那里。你可以创建一个Winform控件来Host这个ActiveX控件,并把Winform控件加入WindowsFormsHost中。

    这样,你可以通过Override Winform控件的WndProc方法来处理相应的消息,或是把消息反馈出来。


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2011年10月15日 5:25
    版主