コード例 #1
0
ファイル: LWECore.cs プロジェクト: cyf-gh/LiveWallpaperEngine
        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);
        }
コード例 #2
0
        public bool SendToBackground(IntPtr handler)
        {
            //处理alt+tab可以看见本程序
            //https://stackoverflow.com/questions/357076/best-way-to-hide-a-window-from-the-alt-tab-program-switcher
            int exStyle = User32Wrapper.GetWindowLong(handler, WindowLongFlags.GWL_EXSTYLE);

            exStyle |= (int)WindowStyles.WS_EX_TOOLWINDOW;
            User32Wrapper.SetWindowLong(handler, WindowLongFlags.GWL_EXSTYLE, exStyle);

            if (handler != _currentHandler)
            {
                //已经换了窗口,恢复上一个窗口
                RestoreParent();
            }

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

            _ = User32Wrapper.GetWindowRect(handler, out _);
            //var ok = User32Wrapper.GetWindowRect(handler, out RECT react);
            //if (ok)
            //    _originalRect = react;

            _currentHandler = handler;

            var workerw = GetWorkerW();

            if (workerw == IntPtr.Zero)
            {
                //有时候突然又不行了,在来一次
                User32Wrapper.SystemParametersInfo(User32Wrapper.SPI_SETCLIENTAREAANIMATION, 0, true, User32Wrapper.SPIF_UPDATEINIFILE | User32Wrapper.SPIF_SENDWININICHANGE);
                workerw = GetWorkerW();
            }

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

            _parentHandler = User32Wrapper.GetParent(_currentHandler);

            //if (newParentHandler != _parentHandler)
            //{
            //    //parent没变时不重复调用,有时候会导致不可见
            User32Wrapper.SetParent(_currentHandler, workerw);
            FullScreen(_currentHandler, _targetBounds, workerw);
            //_parentHandler = newParentHandler;
            //}

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

            return(true);
        }
コード例 #3
0
        public bool SendToBackground(IntPtr handler)
        {
            if (handler != _currentHandler)
            {
                //已经换了窗口,恢复上一个窗口
                RestoreParent();
            }

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

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

            if (ok)
            {
                _originalRect = react;
            }

            _currentHandler = handler;

            var workerw = GetWorkerW();

            if (workerw == IntPtr.Zero)
            {
                //有时候突然又不行了,在来一次
                User32Wrapper.SystemParametersInfo(User32Wrapper.SPI_SETCLIENTAREAANIMATION, 0, true, User32Wrapper.SPIF_UPDATEINIFILE | User32Wrapper.SPIF_SENDWININICHANGE);
                workerw = GetWorkerW();
            }

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

            _parentHandler = User32Wrapper.GetParent(_currentHandler);
            FullScreen(_currentHandler, _targetBounds);
            User32Wrapper.SetParent(_currentHandler, workerw);

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

            return(true);
        }
コード例 #4
0
        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);
        }