Exemplo n.º 1
0
        /// <summary>
        /// Extended window style で操作の透過/戻す
        /// </summary>
        /// <param name="isClickThrough">If set to <c>true</c> is top.</param>
        public void EnableClickThrough(bool isClickThrough)
        {
            if (!IsActive)
            {
                return;
            }

            // Layered Window での透過時は、操作透過はOSで行われる
            if (currentTransparentType == TransparentType.LayereredWindows)
            {
                return;
            }

#if UNITY_EDITOR
            // エディタの場合は操作の透過はやめておく
            //if (isClickThrough)
            //{
            //    long exstyle = this.CurrentWindowExStyle;
            //    exstyle |= WinApi.WS_EX_TRANSPARENT;
            //    //exstyle |= WinApi.WS_EX_LAYERED;
            //    this.CurrentWindowExStyle = exstyle;
            //    WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle);
            //}
            //else
            //{
            //    this.CurrentWindowExStyle = this.OriginalWindowExStyle;
            //    if (enableFileDrop) this.CurrentWindowExStyle |= WinApi.WS_EX_ACCEPTFILES;
            //    WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle);
            //}
#else
            // エディタでなければ操作を透過
            if (isClickThrough)
            {
                long exstyle = this.CurrentWindowExStyle;
                exstyle |= WinApi.WS_EX_TRANSPARENT;
                exstyle |= WinApi.WS_EX_LAYERED;
                this.CurrentWindowExStyle = exstyle;
                WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle);
            }
            else
            {
                this.CurrentWindowExStyle = this.OriginalWindowExStyle;
                if (enableFileDrop)
                {
                    this.CurrentWindowExStyle |= WinApi.WS_EX_ACCEPTFILES;
                }
                WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle);
            }
#endif
        }
Exemplo n.º 2
0
        /// <summary>
        /// SetLayeredWindowsAttributes によって指定色を透過させる
        /// </summary>
        private void DisableTransparentBySetLayered()
        {
#if UNITY_EDITOR
            // エディタの場合、設定すると描画が更新されなくなってしまう
#else
            WinApi.COLORREF cref = new WinApi.COLORREF(0, 0, 0);
            WinApi.SetLayeredWindowAttributes(hWnd, cref, 0xFF, 0x00);

            long exstyle = this.CurrentWindowExStyle;
            exstyle &= ~WinApi.WS_EX_LAYERED;
            this.CurrentWindowExStyle = exstyle;
            WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle);
#endif
        }
Exemplo n.º 3
0
        /// <summary>
        /// SetLayeredWindowsAttributes によって指定色を透過させる
        /// </summary>
        private void EnableTransparentBySetLayered()
        {
#if UNITY_EDITOR
            // エディタの場合、設定すると描画が更新されなくなってしまう
#else
            Color32         color32 = ChromakeyColor;
            WinApi.COLORREF cref    = new WinApi.COLORREF(color32.r, color32.g, color32.b);
            WinApi.SetLayeredWindowAttributes(hWnd, cref, 0xFF, WinApi.LWA_COLORKEY);

            long exstyle = this.CurrentWindowExStyle;
            exstyle |= WinApi.WS_EX_LAYERED;
            this.CurrentWindowExStyle = exstyle;
            WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle);
#endif
        }
Exemplo n.º 4
0
        /// <summary>
        /// ファイルドロップの扱いを終了
        /// </summary>
        public void EndFileDrop()
        {
            EndHook();
            instances.Remove(this);

            if (!IsActive)
            {
                return;
            }

            // ドロップを受け付ける状態を元に戻す
            long exstyle = this.CurrentWindowExStyle;

            exstyle &= ~WinApi.WS_EX_ACCEPTFILES;
            exstyle |= (WinApi.WS_EX_ACCEPTFILES & this.OriginalWindowExStyle); // 元からドロップ許可ならやはり受付
            this.CurrentWindowExStyle = exstyle;
            WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle);
        }
Exemplo n.º 5
0
        /// <summary>
        /// ファイルドロップの扱いを開始
        /// </summary>
        public void BeginFileDrop()
        {
            if (!IsActive)
            {
                EndFileDrop();
                return;
            }

            if (!instances.Contains(this))
            {
                instances.Add(this);
            }
            BeginHook();

            // ドロップを受け付ける状態にする
            long exstyle = this.CurrentWindowExStyle;

            exstyle |= WinApi.WS_EX_ACCEPTFILES;
            this.CurrentWindowExStyle = exstyle;
            WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle);
        }
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);
 }