Exemplo n.º 1
0
        public bool SendToBackground(IntPtr handler, int displayIndex = 0)
        {
            if (handler == IntPtr.Zero || Shown)
            {
                return(false);
            }

            var ok = User32Wrapper.GetWindowRect(handler, out RECT react);

            if (ok)
            {
                _originalRect = react;
            }

            Shown         = true;
            _targeHandler = handler;

            if (_workerw == IntPtr.Zero)
            {
                _workerw = GetWorkerW();
            }

            _parentHandler = User32Wrapper.GetParent(_targeHandler);
            if (_parentHandler == IntPtr.Zero)
            {
                _parentHandler = User32Wrapper.GetAncestor(_targeHandler, GetAncestorFlags.GetParent);
            }

            User32Wrapper.SetParent(_targeHandler, _workerw);

            FullScreen(_targeHandler, displayIndex);

            return(true);
        }
        public bool SendToBackground(IntPtr handler)
        {
            if (Shown && handler != _currentHandler)
            {
                //已经换了窗口,恢复上一个窗口
                RestoreParent(false);
            }

            if (handler == IntPtr.Zero || Shown)
            {
                return(false);
            }

            var ok = User32Wrapper.GetWindowRect(handler, out RECT react);

            if (ok)
            {
                _originalRect = react;
            }

            Shown           = true;
            _currentHandler = handler;

            if (_workerw == IntPtr.Zero)
            {
                _workerw = GetWorkerW();
                if (_workerw == IntPtr.Zero)
                {
                    return(false);
                }
            }

            _parentHandler = User32Wrapper.GetParent(_currentHandler);
            if (_parentHandler == IntPtr.Zero)
            {
                _parentHandler = User32Wrapper.GetAncestor(_currentHandler, GetAncestorFlags.GetParent);
            }

            User32Wrapper.SetParent(_currentHandler, _workerw);

            FullScreen(_currentHandler, DisplayScreen);

            return(true);
        }