private void HookMessage()
            {
                HookProc          proc1;
                MessageHookObject obj1;
                MouseHookManager  manager1;

                GC.KeepAlive(this);
                manager1 = this;
                Monitor.Enter(this);
                try
                {
                    if (this.MessageHookHandle == IntPtr.Zero)
                    {
                        if (this.handle != IntPtr.Zero)
                        {
                            if (this.thisProcessID == 0)
                            {
                                GetWindowThreadProcessId(this.handle, ref this.thisProcessID);
                            }
                        }
                        obj1  = new MessageHookObject(this);
                        proc1 = new HookProc(obj1.Callback);
                        this.MessageHookRoot   = GCHandle.Alloc(proc1);
                        this.MessageHookHandle = SetWindowsHookEx(14, proc1, new IntPtr(GetModuleHandle(null)), 0);
                    }
                }
                finally
                {
                    Monitor.Exit(manager1);
                }
            }
示例#2
0
        private void StartHookMessages()
        {
            GC.KeepAlive(this);
            lock(this)
            {
                if (_messageHookHandle != IntPtr.Zero)
                    return;

                if (thisProcessID == 0)
                    Win32Calls.GetWindowThreadProcessId(new HandleRef(_control, _control.Handle), out thisProcessID);

                MessageHookObject obj = new MessageHookObject(this);
                Win32Calls.HookProc msgHookProc = new Win32Calls.HookProc(obj.Callback);
                _messageHookRoot = GCHandle.Alloc(msgHookProc);

                _messageHookHandle = Win32Calls.SetWindowsHookEx(Win32Calls.WH_CALLWNDPROC, msgHookProc, (IntPtr)0, Win32Calls.GetCurrentThreadId());
            }
        }
示例#3
0
        private void StartHookMessages()
        {
            GC.KeepAlive(this);
            lock (this)
            {
                if (_messageHookHandle != IntPtr.Zero)
                {
                    return;
                }

                if (thisProcessID == 0)
                {
                    Win32Calls.GetWindowThreadProcessId(new HandleRef(_control, _control.Handle), out thisProcessID);
                }

                MessageHookObject   obj         = new MessageHookObject(this);
                Win32Calls.HookProc msgHookProc = new Win32Calls.HookProc(obj.Callback);
                _messageHookRoot = GCHandle.Alloc(msgHookProc);

                _messageHookHandle = Win32Calls.SetWindowsHookEx(Win32Calls.WH_CALLWNDPROC, msgHookProc, (IntPtr)0, Win32Calls.GetCurrentThreadId());
            }
        }
 private void HookMessage()
 {
     HookProc proc1;
     MessageHookObject obj1;
     MouseHookManager manager1;
     GC.KeepAlive(this);
     manager1 = this;
     Monitor.Enter(this);
     try
     {
         if (this.MessageHookHandle == IntPtr.Zero)
         {
             if (this.handle != IntPtr.Zero)
             {
                 if (this.thisProcessID == 0)
                 {
                     GetWindowThreadProcessId(this.handle, ref this.thisProcessID);
                 }
             }
             obj1 = new MessageHookObject(this);
             proc1 = new HookProc(obj1.Callback);
             this.MessageHookRoot = GCHandle.Alloc(proc1);
             this.MessageHookHandle = SetWindowsHookEx(14, proc1, new IntPtr(GetModuleHandle(null)), 0);
         }
     }
     finally
     {
         Monitor.Exit(manager1);
     }
 }