Beispiel #1
0
        /// <summary>
        /// Makes a connection between a specified window handle
        /// and the callback to be called when that message is received.
        /// </summary>
        private WindowHook(IntPtr handle, WndProcCallback callback)
        {
            Debug.Assert(handle != IntPtr.Zero, "Window handle cannot be null");
            Debug.Assert(callback != null, "Callback method should be specified");

            _handle = handle;

            _mainWndProc = WindowProc;
            _callback    = callback;

            // Subclassing window
            _originalWndProc = User32.SetWindowLong(_handle, User32.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(_mainWndProc));
        }
Beispiel #2
0
        /// <summary>
        /// Makes a connection between a specified window handle
        /// and the callback to be called when that message is received.
        /// </summary>
        private WindowHook(IntPtr handle, WndProcCallback callback)
        {
            Debug.Assert(handle != IntPtr.Zero, "Window handle cannot be null");
            Debug.Assert(callback != null, "Callback method should be specified");

            _handle = handle;

            _mainWndProc = WindowProc;
            _callback = callback;

            // Subclassing window
            _originalWndProc = User32.SetWindowLong(_handle, User32.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(_mainWndProc));
        }