예제 #1
0
        /// <summary>
        /// Initializes window proc hook and reads current DPI info
        /// </summary>
        private void InitializeTouchProcedures()
        {
            if (!User32.RegisterTouchWindow(control.Handle, 0))
            {
                throw new ArgumentException("Cannot register touch window.");
            }

            // save a pointer to window proc delegate, otherwise it will get garbage collected
            windowProcDelegate = WindowProcSubClass;

            // According to the SDK doc SetWindowLongPtr should be exported by both 32/64 bit O/S
            // But it does not.
            originalWindowProcId = IntPtr.Size == 4 ?
                                   User32.SubclassWindow(control.Handle, User32.GWLP_WNDPROC, windowProcDelegate) :
                                   User32.SubclassWindow64(control.Handle, User32.GWLP_WNDPROC, windowProcDelegate);

            using (var graphics = System.Drawing.Graphics.FromHwnd(control.Handle))
            {
                dpiX = graphics.DpiX;
                dpiY = graphics.DpiY;
            }
        }
예제 #2
0
        /// <summary>
        /// Connect the handler to the Control
        /// </summary>
        /// <remarks>
        /// The trick is to subclass the Control and intercept touch/gesture events, then reflect
        /// them back to the control.
        /// </remarks>
        private void Initialize()
        {
            if (!SetHWndTouchInfo())
            {
                throw new NotSupportedException("Cannot register window");
            }

            _windowProcDelegate = WindowProcSubClass;

            //According to the SDK doc SetWindowLongPtr should be exported by both 32/64 bit O/S
            //But it does not.
            _originalWindowProcId = IntPtr.Size == 4 ?
                                    User32.SubclassWindow(_hWndWrapper.Handle, User32.GWLP_WNDPROC, _windowProcDelegate) :
                                    User32.SubclassWindow64(_hWndWrapper.Handle, User32.GWLP_WNDPROC, _windowProcDelegate);

            //take the desktop DPI
            using (Graphics graphics = Graphics.FromHwnd(_hWndWrapper.Handle))
            {
                DpiX = graphics.DpiX;
                DpiY = graphics.DpiY;
            }

            WindowMessage += (s, e) => { };
        }
        /// <summary>
        /// Initializes window proc hook and reads current DPI info
        /// </summary>
        private void InitializeTouchProcedures()
        {
            if (!User32.RegisterTouchWindow(control.Handle, 0))
                throw new ArgumentException("Cannot register touch window.");

            // save a pointer to window proc delegate, otherwise it will get garbage collected
            windowProcDelegate = WindowProcSubClass;

            // According to the SDK doc SetWindowLongPtr should be exported by both 32/64 bit O/S
            // But it does not.
            originalWindowProcId = IntPtr.Size == 4 ?
                User32.SubclassWindow(control.Handle, User32.GWLP_WNDPROC, windowProcDelegate) :
                User32.SubclassWindow64(control.Handle, User32.GWLP_WNDPROC, windowProcDelegate);

            using (var graphics = System.Drawing.Graphics.FromHwnd(control.Handle))
            {
                dpiX = graphics.DpiX;
                dpiY = graphics.DpiY;
            }
        }
예제 #4
0
        /// <summary>
        /// Connect the handler to the Control
        /// </summary>
        /// <remarks>
        /// The trick is to subclass the Control and intercept touch/gesture events, then reflect
        /// them back to the control.
        /// </remarks>
        private void Initialize()
        {
            if (!SetHWndTouchInfo())
            {
                throw new NotSupportedException("Cannot register window");
            }

            _windowProcDelegate = WindowProcSubClass;

            //According to the SDK doc SetWindowLongPtr should be exported by both 32/64 bit O/S
            //But it does not.
            _originalWindowProcId = IntPtr.Size == 4 ?
                User32.SubclassWindow(_hWndWrapper.Handle, User32.GWLP_WNDPROC, _windowProcDelegate) :
                User32.SubclassWindow64(_hWndWrapper.Handle, User32.GWLP_WNDPROC, _windowProcDelegate);

            //take the desktop DPI
            using (Graphics graphics = Graphics.FromHwnd(_hWndWrapper.Handle))
            {
                IntPtr desktop = graphics.GetHdc();

                int Xdpi = User32.GetDeviceCaps(desktop, (int)User32.DeviceCap.LOGPIXELSX);
                int Ydpi = User32.GetDeviceCaps(desktop, (int)User32.DeviceCap.LOGPIXELSY);
                DpiX = Xdpi;
                DpiY = Ydpi;
            }

            //WindowMessage += (s, e) => { };
        }