Exemplo n.º 1
0
 /// <summary>
 /// 最大化または最小化したウィンドウを元に戻す
 /// </summary>
 public void Restore()
 {
     if (!IsActive)
     {
         return;
     }
     WinApi.ShowWindow(hWnd, WinApi.SW_RESTORE);
     this.CurrentWindowStyle = WinApi.GetWindowLong(hWnd, WinApi.GWL_STYLE);
 }
Exemplo n.º 2
0
 /// <summary>
 /// ウィンドウ最小化
 /// </summary>
 public void Minimize()
 {
     if (!IsActive)
     {
         return;
     }
     this.CurrentWindowStyle = WinApi.GetWindowLong(hWnd, WinApi.GWL_STYLE);
     WinApi.ShowWindow(hWnd, WinApi.SW_MINIMIZE);
 }
Exemplo n.º 3
0
        /// <summary>
        /// ウィンドウ透過をON/OFF
        /// </summary>
        public void EnableTransparent(bool enable)
        {
            if (!IsActive)
            {
                return;
            }

            if (enable)
            {
                // 現在のウィンドウ情報を記憶
                StoreWindowSize();

                // 枠無しウィンドウにする
                EnableBorderless(true);

                switch (TransparentMethod)
                {
                case TransparentType.DWM:
                    EnableTransparentByDWM();
                    break;

                case TransparentType.LayereredWindows:
                    EnableTransparentBySetLayered();
                    break;
                }
            }
            else
            {
                // 現在の指定ではなく、透過にした時点の指定に基づいて無効化
                switch (currentTransparentType)
                {
                case TransparentType.DWM:
                    DisableTransparentByDWM();
                    break;

                case TransparentType.LayereredWindows:
                    DisableTransparentBySetLayered();
                    break;
                }

                // 枠ありウィンドウにする
                EnableBorderless(false);

                // 操作の透過をやめる
                EnableClickThrough(false);
            }

            currentTransparentType = TransparentMethod;

            // サイズ変更イベントを発生させる
            SetSize(GetSize());

            // ウィンドウ再描画
            WinApi.ShowWindow(hWnd, WinApi.SW_SHOW);
        }
Exemplo n.º 4
0
        /// <summary>
        /// ウィンドウ透過をON/OFF
        /// </summary>
        public void EnableTransparent(bool enable)
        {
            if (!IsActive)
            {
                return;
            }

            if (enable)
            {
                // 現在のウィンドウ情報を記憶
                StoreWindowSize();

                // 枠無しウィンドウにする
                EnableBorderless(true);

                switch (TransparentType)
                {
                case TransparentTypes.Alpha:
                    EnableTransparentByDWM();
                    break;

                case TransparentTypes.ColorKey:
                    EnableTransparentBySetLayered();
                    break;
                }
            }
            else
            {
                // 現在の指定ではなく、透過にした時点の指定に基づいて無効化
                switch (_currentTransparentType)
                {
                case TransparentTypes.Alpha:
                    DisableTransparentByDWM();
                    break;

                case TransparentTypes.ColorKey:
                    DisableTransparentBySetLayered();
                    break;
                }

                // 枠ありウィンドウにする
                EnableBorderless(false);

                // 操作の透過をやめる
                EnableClickThrough(false);
            }

            _currentTransparentType = TransparentType;

            // ウィンドウ枠の分サイズが変わった際、Unityにリサイズイベントを発生させないとサイズがずれる
            ResetSize();

            // ウィンドウ再描画
            WinApi.ShowWindow(hWnd, WinApi.SW_SHOW);
        }
Exemplo n.º 5
0
        /// <summary>
        /// ウィンドウ透過をON/OFF
        /// </summary>
        public void EnableTransparent(bool enable)
        {
            if (!IsActive)
            {
                return;
            }

            if (enable)
            {
                // 現在のウィンドウ情報を記憶
                StoreWindowSize();

                // 枠無しウィンドウにする
                EnableBorderless(true);

                EnableTransparentByDWM();

                // ウィンドウ再描画
                WinApi.ShowWindow(hWnd, WinApi.SW_SHOW);
                SetSize(GetSize());
            }
            else
            {
                DisableTransparentByDWM();

                // ウィンドウスタイルを戻す
                EnableBorderless(false);

                // 操作の透過をやめる
                EnableClickThrough(false);

                // サイズ変更イベントを発生させる
                SetSize(GetSize());
            }

            // ウィンドウ再描画
            WinApi.ShowWindow(hWnd, WinApi.SW_SHOW);
        }
Exemplo n.º 6
0
        /// <summary>
        /// ウィンドウスタイルを監視して、替わっていれば戻す
        /// </summary>
        public void Update()
        {
            if (!IsActive)
            {
                return;
            }
            long style   = WinApi.GetWindowLong(hWnd, WinApi.GWL_STYLE);
            long exstyle = WinApi.GetWindowLong(hWnd, WinApi.GWL_EXSTYLE);

            if (!WinApi.IsIconic(hWnd) && !WinApi.IsZoomed(hWnd))
            {
                if (style != this.CurrentWindowStyle)
                {
                    WinApi.SetWindowLong(hWnd, WinApi.GWL_STYLE, this.CurrentWindowStyle);
                    WinApi.ShowWindow(hWnd, WinApi.SW_SHOW);
                }
                if (exstyle != this.CurrentWindowExStyle)
                {
                    WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle);
                    WinApi.ShowWindow(hWnd, WinApi.SW_SHOW);
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// ウィンドウスタイルを最初のものに戻す
 /// </summary>
 private void RestoreWindowState()
 {
     WinApi.SetWindowLong(hWnd, WinApi.GWL_STYLE, this.OriginalWindowStyle);
     WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.OriginalWindowExStyle);
     WinApi.ShowWindow(hWnd, WinApi.SW_SHOW);
 }
Exemplo n.º 8
0
        /// <summary>
        /// ウィンドウ透過をON/OFF
        /// </summary>
        public void EnableTransparent(bool enable)
        {
            if (!IsActive)
            {
                return;
            }

            bool maximized = IsMaximized;

            // 最大化状態ならば、一度通常ウィンドウに戻してから透過・枠有無を変更する
            if (maximized)
            {
                Restore();
            }

            if (enable)
            {
                // 現在のウィンドウ情報を記憶
                StoreWindowSize();

                // 枠無しウィンドウにする
                EnableBorderless(true);

                switch (TransparentType)
                {
                case TransparentTypes.Alpha:
                    EnableTransparentByDWM();
                    break;

                case TransparentTypes.ColorKey:
                    EnableTransparentBySetLayered();
                    break;
                }
            }
            else
            {
                // 現在の指定ではなく、透過にした時点の指定に基づいて無効化
                switch (_currentTransparentType)
                {
                case TransparentTypes.Alpha:
                    DisableTransparentByDWM();
                    break;

                case TransparentTypes.ColorKey:
                    DisableTransparentBySetLayered();
                    break;
                }

                // 枠ありウィンドウにする
                EnableBorderless(false);

                // 操作の透過をやめる
                EnableClickThrough(false);
            }

            // 戻す方法を決めるため、透明化が変更された時のタイプを記録しておく
            _currentTransparentType = TransparentType;

            // 呼ぶ前に最大化状態だったならば、再度最大化
            if (maximized)
            {
                // ウィンドウ再描画は最大化時に行われる
                Maximize();
            }
            else
            {
                // ウィンドウ枠の分サイズが変わった際、Unityにリサイズイベントを発生させないとサイズがずれる
                ResetSize();

                // ウィンドウ再描画
                WinApi.ShowWindow(hWnd, WinApi.SW_SHOW);
            }
        }