Windows デベロッパー センター > Windows クライアント開発 フォーラム > Windows クライアント開発 - 全般 > Windows7 マルチタッチ:WPFコントロールへのWM_TOUCHの飛ばし方について
質問する質問する
 

質問Windows7 マルチタッチ:WPFコントロールへのWM_TOUCHの飛ばし方について

  • 2009年10月9日 6:39せれ ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    お世話になります。
    Windows 7 SDKを利用してVS2008 C#+WPFでマルチタッチイベントの勉強をしております。
    WPFのUserControlにWM_TOUCHメッセージを飛ばしたいと思っております。

    _________________________
    |                     |                    |
    |       WPF        |                    |
    |  User Control |                    |
    |                     |                    |
    |____________|___________ |

    上記のようにWinFormアプリケーションのウィンドウ左半分にWPFのUserControlをホストし、
    マルチタッチイベントの確認をしているのですが、

    ①メインウィンドウにSample:MTGesturesのMTGestureFormクラスを継承
      →WPF USer Control領域、及び、WinForm領域でWM_GESTUREメッセージが飛んでくる

    ②メインウィンドウにSample:MTScratchpadWMTouchのMTTouchFormクラスを継承
        →WPF USer Control領域ではWM_TOUCHが飛んでこない(WinForm領域では飛んでくる)

    という状況です。

    http://blog.andreweichacker.com/2009/02/windows-7-multi-touch-using-wpf/
    で、WPFでマルチタッチを使うコード例が示されているのですが、

    public Window1() {
                InitializeComponent();
     
                // here's the first thing you need to do.  upon window load, you want to set the tablet
                // property to receive multi-touch data.  you need to the window loaded to ensure the handle is created.
                this.Loaded += new RoutedEventHandler(
                   delegate(object sender, RoutedEventArgs args)
                   {
                       var source = new WindowInteropHelper(this); ← ※※※
                 ・・・・

    ※※※の所で、WPF UserControlの親ウィンドウの取得方法がわからず、前に進むことができませんでした。
    (以下のコードを試しましたが、parentにnullが返ってきました。

     public UserControl1()
            {
                InitializeComponent();
                this.Loaded += new RoutedEventHandler(UserControl1_Loaded);
            }

            void UserControl1_Loaded(object sender, RoutedEventArgs e)
            {
                Window parent = Window.GetWindow(this);
            }
    )


    やりたいことはWPF UserControl領域をタッチするとWM_TOUCHが飛ぶようにすることなんですが、
    お知恵を拝借できれば幸いです。

    以上、よろしくお願いします。