Exemple #1
0
        internal IntPtr CriticalAttach(IntPtr hwnd)
        {
            if (hwnd == IntPtr.Zero)
            {
                throw new ArgumentNullException("hwnd");
            }
            if (_bond != Bond.Unattached)
            {
                throw new InvalidOperationException();
            }

            NativeMethods.WndProc newWndProc = new NativeMethods.WndProc(SubclassWndProc);
            IntPtr oldWndProc = UnsafeNativeMethods.GetWindowLongPtr(new HandleRef(this, hwnd), NativeMethods.GWL_WNDPROC);

            HookWindowProc(hwnd, newWndProc, oldWndProc);

            // Return the GC handle as a unique identifier of this
            return((IntPtr)_gcHandle);
        }