Example #1
0
        public void SubClass(IntPtr owner)
        {
            Debug.WriteLine("SubClass(): " + owner);

            var pt = Win32.GetCursorPos();
            var pt1 = new Win32.POINT(pt.X, pt.Y);

            _owner = owner == IntPtr.Zero ? Win32.WindowFromPoint(pt1) : owner;

            if (_owner == IntPtr.Zero)
                throw new NullReferenceException("Can't find owner");

            _root = Win32.GetAncestor(_owner, Win32.GA_ROOT);
            if (_root == IntPtr.Zero)
                throw new NullReferenceException("Can't find root");

            _ownerWndProc = WndProc;
                                _oldOwner = Win32.SetWindowProc(_owner, _ownerWndProc);

            if (_oldOwner == IntPtr.Zero)
                throw new InvalidOperationException("Failed subclass");

            _rootWndProc = RootWndProc;
                                _oldRoot = Win32.SetWindowProc(_root, _rootWndProc);

            if (_oldRoot == IntPtr.Zero)
                throw new InvalidOperationException("Failed subclass");
        }
Example #2
0
        public void SubClass(IntPtr owner)
        {
            Debug.WriteLine("SubClass(): " + owner);

            var pt  = Win32.GetCursorPos();
            var pt1 = new Win32.POINT(pt.X, pt.Y);

            _owner = owner == IntPtr.Zero ? Win32.WindowFromPoint(pt1) : owner;

            if (_owner == IntPtr.Zero)
            {
                throw new NullReferenceException("Can't find owner");
            }

            _root = Win32.GetAncestor(_owner, Win32.GA_ROOT);
            if (_root == IntPtr.Zero)
            {
                throw new NullReferenceException("Can't find root");
            }

            _ownerWndProc = WndProc;
            _oldOwner     = Win32.SetWindowProc(_owner, _ownerWndProc);

            if (_oldOwner == IntPtr.Zero)
            {
                throw new InvalidOperationException("Failed subclass");
            }

            _rootWndProc = RootWndProc;
            _oldRoot     = Win32.SetWindowProc(_root, _rootWndProc);

            if (_oldRoot == IntPtr.Zero)
            {
                throw new InvalidOperationException("Failed subclass");
            }
        }