locked
RegisterPointerInputTarget return false RRS feed

  • Question

  • Hi I'm trying to upgrade a .Net project running well on Windows7 to Windows8. This program use touch screen capacities.

    On my Windows7 project my code in C# works fine and use the following implementation:

        [DllImport("User32")]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool RegisterTouchWindow(IntPtr handle, UInt32 flags);

         public AtlEventTouch(IntPtr handle)
        {
            IntPtr hwnd = GetModuleHandle("User32");
            UIntPtr address = GetProcAddress(hwnd, "RegisterTouchWindow");

            if (address != UIntPtr.Zero)
            {
              if (RegisterTouchWindow(handle, 0))                          //<= Here RegisterTouchWindow return true as expected
                _flagTouchCapable = true;                                       // so my flag is set to true
            }
        }

    But now with Windows8 I wish to use the new Api function RegisterPointerInputTarget, so I tried this : 

        [DllImport("User32")]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool RegisterPointerInputTarget(IntPtr handle, PointerInputType flags);

        public AtlEventTouch(IntPtr handle)
        {
            IntPtr hwnd = GetModuleHandle("User32");
            UIntPtr address = GetProcAddress(hwnd, "RegisterPointerInputTarget");

            if (address != UIntPtr.Zero)
            {
              if (RegisterPointerInputTarget(handle, PointerInputType.TOUCH))             //<= Here RegisterPointerInputTarget return FALSE
                _flagTouchCapable = true;                                                                        // so my flag is NOT set to true
            }
        }

       

         public enum PointerInputType
        {

            POINTER = 0x00000001,

            TOUCH = 0x00000002,

            PEN = 0x00000003,

            MOUSE = 0x00000004,

        }

    Is it the way I describe the RegisterPointerInputTarget function in my DllImport ?

    Friday, March 22, 2013 3:06 PM