Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hWnd"></param>
        public MessageHook(IntPtr hWnd, uint threadId)
        {
            this.hWnd = hWnd;

            _threadId  = threadId;
            cachedHook = WndProcHook;
            CreateHook();
        }
Ejemplo n.º 2
0
 public HTCNavSensor(Control control)
 {
     this.myHandler = new WndProcHandler(this.WndProc);
     this.myControl = control;
     HTCNavOpen(control.Handle, 1);
     HTCNavSetMode(control.Handle, HTCAPIMode.Gesture);
     this.myOldWndProc = SetWindowLong(control.Handle, WindowLong.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(this.myHandler));
 }
Ejemplo n.º 3
0
 public HTCNavSensor(Control control)
 {
     this.myHandler = new WndProcHandler(this.WndProc);
     this.myControl = control;
     HTCNavOpen(control.Handle, 1);
     HTCNavSetMode(control.Handle, HTCAPIMode.Gesture);
     this.myOldWndProc = SetWindowLong(control.Handle, WindowLong.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(this.myHandler));
 }
Ejemplo n.º 4
0
 public HTCNavSensor(Form form)
 {
     myHandler = new WndProcHandler(WndProc);
     myForm = form;
     myOldWndProc = SetWindowLong(form.Handle, WindowLong.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(myHandler));
     int ret = HTCNativeMethods.HTCNavOpen(form.Handle, HTCNativeMethods.HTCNavOpenAPI);
     ret = HTCNativeMethods.HTCNavSetMode(form.Handle, HTCAPIMode.Gesture);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hWnd"></param>
        public MessageHook(IntPtr hWnd, uint threadId)
        {
            this.hWnd = hWnd;

            _threadId = threadId;
            cachedHook = WndProcHook;
            CreateHook();
        }
Ejemplo n.º 6
0
        public HTCNavSensor(Form form)
        {
            myHandler    = new WndProcHandler(WndProc);
            myForm       = form;
            myOldWndProc = SetWindowLong(form.Handle, WindowLong.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(myHandler));
            int ret = HTCNativeMethods.HTCNavOpen(form.Handle, HTCNativeMethods.HTCNavOpenAPI);

            ret = HTCNativeMethods.HTCNavSetMode(form.Handle, HTCAPIMode.Gesture);
        }
Ejemplo n.º 7
0
 protected MessageHook(IntPtr hWnd)
 {
     _wnd         = hWnd;
     _hook        = WndProcHook;
     _prevWndProc = (IntPtr)NativeMethods.SetWindowLong(
         hWnd,
         NativeConstants.GWL_WNDPROC, (int)Marshal.GetFunctionPointerForDelegate(_hook));
     _hIMC = NativeMethods.ImmGetContext(_wnd);
     Application.AddMessageFilter(new InputMessageFilter(_hook));
 }
Ejemplo n.º 8
0
 public MessageHook(IntPtr hWnd)
 {
     HWnd          = hWnd;
     m_Hook        = WndProcHook;
     m_PrevWndProc = (IntPtr)NativeMethods.SetWindowLong(
         hWnd,
         NativeConstants.GwlWndproc, (int)Marshal.GetFunctionPointerForDelegate(m_Hook));
     m_HImc = NativeMethods.ImmGetContext(HWnd);
     new InputMessageFilter(m_Hook);
 }
Ejemplo n.º 9
0
 public MessageHook(IntPtr hWnd)
 {
     HWnd = hWnd;
     m_Hook = WndProcHook;
     m_PrevWndProc = (IntPtr)NativeMethods.SetWindowLong(
         hWnd,
         NativeConstants.GwlWndproc, (int)Marshal.GetFunctionPointerForDelegate(m_Hook));
     m_HImc = NativeMethods.ImmGetContext(HWnd);
     new InputMessageFilter(m_Hook);
 }
Ejemplo n.º 10
0
 public MessageHook(IntPtr hWnd)
 {
     m_hWnd        = hWnd;
     m_Hook        = WndProcHook;
     m_prevWndProc = (IntPtr)NativeMethods.SetWindowLong(
         hWnd,
         NativeConstants.GWL_WNDPROC, (int)Marshal.GetFunctionPointerForDelegate(m_Hook));
     m_hIMC = NativeMethods.ImmGetContext(m_hWnd);
     new InputMessageFilter(m_Hook);
 }
Ejemplo n.º 11
0
 public MessageHook(IntPtr hWnd)
 {
     m_hWnd = hWnd;
     m_Hook = WndProcHook;
     m_prevWndProc = (IntPtr)NativeMethods.SetWindowLong(
         hWnd,
         NativeConstants.GWL_WNDPROC, (int)Marshal.GetFunctionPointerForDelegate(m_Hook));
     m_hIMC = NativeMethods.ImmGetContext(m_hWnd);
     new InputMessageFilter(m_Hook);
 }
Ejemplo n.º 12
0
 public InputMessageFilter(WndProcHandler hook)
 {
     m_Hook = hook;
     Application.AddMessageFilter(this);
 }
Ejemplo n.º 13
0
 public static extern IntPtr SetWindowsHookEx(int hookType, WndProcHandler callback, IntPtr hMod, uint dwThreadId);
Ejemplo n.º 14
0
        private void CreateWindow(string className)
        {
            if (className == null)
            {
                throw new Exception("class_name is null");
            }
            if (className == String.Empty)
            {
                throw new Exception("class_name is empty");
            }

            _wndProcDelegate = CustomWndProc;

            gcHandle = GCHandle.Alloc(_wndProcDelegate);

            WNDCLASS windClass = new WNDCLASS
            {
                lpszClassName = className,
                lpfnWndProc   = Marshal.GetFunctionPointerForDelegate(_wndProcDelegate)
            };

            ushort classAtom = User32.RegisterClassW(ref windClass);

            int lastError = Marshal.GetLastWin32Error();

            if (classAtom == 0 && lastError != ERROR_CLASS_ALREADY_EXISTS)
            {
                throw new Exception("Could not register window class");
            }

            const UInt32 extendedStyle = (UInt32)(
                WindowExStyles.WS_EX_LEFT |
                WindowExStyles.WS_EX_LTRREADING |
                WindowExStyles.WS_EX_RIGHTSCROLLBAR |
                WindowExStyles.WS_EX_TOOLWINDOW);

            const UInt32 style = (UInt32)(
                WindowStyles.WS_CLIPSIBLINGS |
                WindowStyles.WS_CLIPCHILDREN |
                WindowStyles.WS_POPUP);

            var owner = User32.GetWindow(_parentHandle, 4);

            // Create window
            _handle = User32.CreateWindowExW(
                extendedStyle,
                className,
                className,
                style,
                0,
                0,
                0,
                0,
                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero
                );

            if (_handle == IntPtr.Zero)
            {
                return;
            }

            uint styles = User32.GetWindowLong(_handle, GetWindowLongFlags.GWL_EXSTYLE);

            styles = styles | (int)WindowExStyles.WS_EX_LAYERED | (int)WindowExStyles.WS_EX_NOACTIVATE | (int)WindowExStyles.WS_EX_TRANSPARENT;
            User32.SetWindowLong(_handle, GetWindowLongFlags.GWL_EXSTYLE, styles);
        }
Ejemplo n.º 15
0
        private void CreateWindow(string className)
        {
            if (className == null)
            {
                throw new Exception("class_name is null");
            }
            if (className == String.Empty)
            {
                throw new Exception("class_name is empty");
            }

            _wndProcDelegate = CustomWndProc;

            gcHandle = GCHandle.Alloc(_wndProcDelegate);

            WNDCLASS windClass = new WNDCLASS
            {
                lpszClassName = className,
                lpfnWndProc   = Marshal.GetFunctionPointerForDelegate(_wndProcDelegate)
            };

            ushort classAtom = User32.RegisterClassW(ref windClass);

            int lastError = Marshal.GetLastWin32Error();

            if (classAtom == 0 && lastError != ERROR_CLASS_ALREADY_EXISTS)
            {
                throw new Exception("Could not register window class");
            }

            uint extendedStyle = (uint)(
                WindowExStyles.WS_EX_LEFT |
                WindowExStyles.WS_EX_LTRREADING |
                WindowExStyles.WS_EX_RIGHTSCROLLBAR |
                WindowExStyles.WS_EX_TOOLWINDOW);



            const uint style = (uint)(
                WindowStyles.WS_CLIPSIBLINGS |
                WindowStyles.WS_CLIPCHILDREN |
                WindowStyles.WS_POPUP);


            // Create window
            Handle = User32.CreateWindowExW(
                extendedStyle,
                className,
                className,
                style,
                0,
                0,
                0,
                0,
                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero
                );

            if (Handle == IntPtr.Zero)
            {
                return;
            }

            var styles = (int)User32.GetWindowLongPtr(Handle, WindowLongFlags.GWL_EXSTYLE);

            //var owner = User32.GetWindow(_parentHandle, 4);

            //User32.SetWindowLong(Handle, GetWindowLongFlags.GWL_HWNDPARENT, owner);

            styles |= (int)(WindowExStyles.WS_EX_LAYERED | WindowExStyles.WS_EX_NOACTIVATE | WindowExStyles.WS_EX_NOPARENTNOTIFY);

            if (!_decorator.Resizable)
            {
                styles |= (int)WindowExStyles.WS_EX_TRANSPARENT;
            }

            User32.SetWindowLongPtr(Handle, WindowLongFlags.GWL_EXSTYLE, new IntPtr(styles));

            _screenDC = User32.GetDC(IntPtr.Zero);
            _memDC    = Gdi32.CreateCompatibleDC(_screenDC);

            D2D1.D2D1CreateFactory(FactoryType.SingleThreaded, out _d2dFactory);
        }
Ejemplo n.º 16
0
        private void CreateWindow(string className)
        {
            if (className == null)
            {
                throw new Exception("class_name is null");
            }
            if (className == String.Empty)
            {
                throw new Exception("class_name is empty");
            }

            _wndProcDelegate = CustomWndProc;

            gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(_wndProcDelegate);

            WNDCLASS windClass = new WNDCLASS
            {
                cbClsExtra    = 0,
                cbWndExtra    = 0,
                hbrBackground = IntPtr.Zero,
                hCursor       = IntPtr.Zero,
                hIcon         = IntPtr.Zero,
                lpfnWndProc   = Marshal.GetFunctionPointerForDelegate(_wndProcDelegate),
                lpszClassName = className,
                lpszMenuName  = null,
                style         = 0
            };

            ushort classAtom = User32.RegisterClassW(ref windClass);

            int lastError = Marshal.GetLastWin32Error();

            if (classAtom == 0 && lastError != ERROR_CLASS_ALREADY_EXISTS)
            {
                throw new Exception("Could not register window class");
            }


            var owner = User32.GetWindow(_parentHandle, GetWindowCommands.GW_OWNER);

            _handle = User32.CreateWindowEx(
                (int)(WindowExStyles.WS_EX_LEFT | WindowExStyles.WS_EX_LTRREADING | WindowExStyles.WS_EX_LAYERED | WindowExStyles.WS_EX_TOOLWINDOW | WindowExStyles.WS_EX_RIGHTSCROLLBAR | WindowExStyles.WS_EX_NOACTIVATE | WindowExStyles.WS_EX_TRANSPARENT),
                new IntPtr(classAtom),
                className,
                //-(WindowStyles.WS_VISIBLE | WindowStyles.WS_MINIMIZE | WindowStyles.WS_CHILDWINDOW | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_DISABLED | WindowStyles.WS_POPUP),
                (WindowStyles.WS_POPUP | WindowStyles.WS_VISIBLE | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_CLIPCHILDREN),
                0, 0, 0, 0, owner, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

            if (_handle == IntPtr.Zero)
            {
                return;
            }

            //const UInt32 extendedStyle = (UInt32)(
            //	WindowExStyles.WS_EX_LEFT |
            //	WindowExStyles.WS_EX_LTRREADING |
            //	WindowExStyles.WS_EX_RIGHTSCROLLBAR |
            //	WindowExStyles.WS_EX_TOOLWINDOW);

            //const UInt32 style = (UInt32)(
            //	WindowStyles.WS_CLIPSIBLINGS |
            //	WindowStyles.WS_CLIPCHILDREN |
            //	WindowStyles.WS_POPUP);

            //// Create window
            //_handle = User32.CreateWindowExW(
            //	extendedStyle,
            //	className,
            //	className,
            //	style,
            //	0,
            //	0,
            //	0,
            //	0,
            //	IntPtr.Zero,
            //	IntPtr.Zero,
            //	IntPtr.Zero,
            //	IntPtr.Zero
            //);

            //if (_handle == IntPtr.Zero)
            //{
            //	return;
            //}

            //uint styles = User32.GetWindowLong(_handle, GetWindowLongFlags.GWL_EXSTYLE);
            //styles = styles | (int)WindowExStyles.WS_EX_LAYERED | (int)WindowExStyles.WS_EX_NOACTIVATE | (int)WindowExStyles.WS_EX_TRANSPARENT;
            //User32.SetWindowLong(_handle, GetWindowLongFlags.GWL_EXSTYLE, styles);
        }
Ejemplo n.º 17
0
 public InputMessageFilter(WndProcHandler hook)
 {
     _Hook = hook;
     System.Windows.Forms.Application.AddMessageFilter(this);
 }
Ejemplo n.º 18
0
 internal static extern IntPtr SetWindowsHookEx(int hookType, WndProcHandler callback, IntPtr hMod, uint dwThreadId);
Ejemplo n.º 19
0
 public InputMessageFilter(WndProcHandler hook)
 {
     m_Hook = hook;
     Application.AddMessageFilter(this);
 }
Ejemplo n.º 20
0
 public InputMessageFilter(WndProcHandler hook)
 {
     m_Hook = hook;
 }
Ejemplo n.º 21
0
 public InputMessageFilter(WndProcHandler hook)
 {
     m_Hook = hook;
 }
Ejemplo n.º 22
0
 public InputMessageFilter(WndProcHandler hook)
 {
     _Hook = hook;
     System.Windows.Forms.Application.AddMessageFilter(this);
 }