コード例 #1
0
        private void buttonRestoreSize_Click(object sender, EventArgs e)
        {
            const uint SWP_NOMOVE   = 0x0002;
            const uint SWP_NOZORDER = 0x0004;

            if (this.hwndExplorer != IntPtr.Zero)
            {
                Size size = this.InitialSize;

                PInvoke_QTWM.SetWindowPos(this.hwndExplorer, IntPtr.Zero, 0, 0, size.Width, size.Height, SWP_NOMOVE | SWP_NOZORDER);

                QTWindowManager.RemoveMAXIMIZE(this.hwndExplorer);
            }
        }
コード例 #2
0
        private void buttonRestoreLoc_Click(object sender, EventArgs e)
        {
            const uint SWP_NOSIZE   = 0x0001;
            const uint SWP_NOZORDER = 0x0004;

            if (this.hwndExplorer != IntPtr.Zero)
            {
                Point pnt = this.InitialLocation;

                PInvoke_QTWM.SetWindowPos(this.hwndExplorer, IntPtr.Zero, pnt.X, pnt.Y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

                QTWindowManager.RemoveMAXIMIZE(this.hwndExplorer);
            }
        }
コード例 #3
0
        private void DoPresetsCore(Rectangle rct)
        {
            IntPtr hwnd = this.pluginServer.ExplorerHandle;

            if (hwnd != IntPtr.Zero)
            {
                uint uFlags = SWP_NOZORDER;

                //if( rct.X == 0 && rct.Y == 0 )
                //    uFlags |= SWP_NOMOVE;
                //if( rct.Width == 0 && rct.Height == 0 )
                //    uFlags |= SWP_NOSIZE;

                PInvoke_QTWM.SetWindowPos(hwnd, IntPtr.Zero, rct.X, rct.Y, rct.Width, rct.Height, uFlags);
                QTWindowManager.RemoveMAXIMIZE(hwnd);
            }
        }
コード例 #4
0
        private void MoveWindow(int index)
        {
            IntPtr hwnd = this.pluginServer.ExplorerHandle;

            if (hwnd == IntPtr.Zero)
            {
                return;
            }

            RECT rct;

            PInvoke_QTWM.GetWindowRect(hwnd, out rct);

            int x = rct.left;
            int y = rct.top;

            switch (index)
            {
            case 8:
                // left
                x -= this.ResizeDelta;
                break;

            case 9:
                // right
                x += this.ResizeDelta;
                break;

            case 10:
                // up
                y -= this.ResizeDelta;
                break;

            case 11:
                // down
                y += this.ResizeDelta;
                break;
            }

            PInvoke_QTWM.SetWindowPos(hwnd, IntPtr.Zero, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

            QTWindowManager.RemoveMAXIMIZE(hwnd);
        }
コード例 #5
0
        private void RestoreInitialSize()
        {
            bool fLoc    = (this.ConfigValues[0] & 0x20) != 0;
            bool fSiz    = (this.ConfigValues[0] & 0x80) != 0;
            bool fPreset = (this.ConfigValues[0] & 0x10) != 0;

            if (fLoc || fSiz || fPreset)
            {
                IntPtr hwnd = this.pluginServer.ExplorerHandle;
                if (hwnd != IntPtr.Zero)
                {
                    if (PInvoke_QTWM.IsZoomed(hwnd))
                    {
                        const int SW_RESTORE = 9;
                        PInvoke_QTWM.ShowWindow(hwnd, SW_RESTORE);
                    }

                    if (fPreset)
                    {
                        if (!String.IsNullOrEmpty(this.startingPreset) && this.dicPresets.ContainsKey(this.startingPreset))
                        {
                            Rectangle rctPreset = this.dicPresets[this.startingPreset];
                            PInvoke_QTWM.SetWindowPos(hwnd, IntPtr.Zero, rctPreset.X, rctPreset.Y, rctPreset.Width, rctPreset.Height, SWP_NOZORDER);
                            QTWindowManager.RemoveMAXIMIZE(hwnd);
                        }
                        return;
                    }

                    uint uFlags = SWP_NOZORDER | (fLoc ? 0 : SWP_NOMOVE) | (fSiz ? 0 : SWP_NOSIZE);

                    PInvoke_QTWM.SetWindowPos(
                        hwnd,
                        IntPtr.Zero,
                        this.pntInitial.X,
                        this.pntInitial.Y,
                        this.sizeInitial.Width,
                        this.sizeInitial.Height,
                        uFlags);

                    QTWindowManager.RemoveMAXIMIZE(hwnd);
                }
            }
        }
コード例 #6
0
        private void ResizeWindow(int index)
        {
            IntPtr hwnd = this.pluginServer.ExplorerHandle;

            if (hwnd == IntPtr.Zero)
            {
                return;
            }

            RECT rct;

            PInvoke_QTWM.GetWindowRect(hwnd, out rct);

            bool fAuto = (this.ConfigValues[0] & 0x40) == 0;

            int  x      = rct.left;
            int  y      = rct.top;
            int  w      = rct.Width;
            int  h      = rct.Height;
            uint uFlags = SWP_NOZORDER;

            switch (index)
            {
            case 1:
                //Enlarge window
                if (fAuto)
                {
                    x -= this.ResizeDelta;
                    y -= this.ResizeDelta;
                    w += this.ResizeDelta * 2;
                    h += this.ResizeDelta * 2;
                }
                else
                {
                    w      += this.ResizeDelta;
                    h      += this.ResizeDelta;
                    uFlags |= SWP_NOMOVE;
                }
                break;

            case 2:
                //Shrink window
                if (fAuto)
                {
                    x += this.ResizeDelta;
                    y += this.ResizeDelta;
                    w -= this.ResizeDelta * 2;
                    h -= this.ResizeDelta * 2;
                }
                else
                {
                    w      -= this.ResizeDelta;
                    h      -= this.ResizeDelta;
                    uFlags |= SWP_NOMOVE;
                }
                break;

            case 3:
                //Widen window
                if (fAuto)
                {
                    x -= this.ResizeDelta;
                    w += this.ResizeDelta * 2;
                }
                else
                {
                    w      += this.ResizeDelta;
                    uFlags |= SWP_NOMOVE;
                }
                break;

            case 4:
                //Narrow widnow
                if (fAuto)
                {
                    x += this.ResizeDelta;
                    w -= this.ResizeDelta * 2;
                }
                else
                {
                    w      -= this.ResizeDelta;
                    uFlags |= SWP_NOMOVE;
                }
                break;

            case 5:
                //Heighten window
                if (fAuto)
                {
                    y -= this.ResizeDelta;
                    h += this.ResizeDelta * 2;
                }
                else
                {
                    h      += this.ResizeDelta;
                    uFlags |= SWP_NOMOVE;
                }
                break;

            case 6:
                //Lower window
                if (fAuto)
                {
                    y += this.ResizeDelta;
                    h -= this.ResizeDelta * 2;
                }
                else
                {
                    h      -= this.ResizeDelta;
                    uFlags |= SWP_NOMOVE;
                }
                break;

            case 7:
                //Restore size
                w       = this.sizeInitial.Width;
                h       = this.sizeInitial.Height;
                uFlags |= SWP_NOMOVE;
                break;
            }


            if (fAuto)
            {
                Rectangle rctScreen = Screen.FromHandle(hwnd).Bounds;

                if (x < rctScreen.X)
                {
                    x = rctScreen.X;

                    if (index == 7)
                    {
                        uFlags &= ~SWP_NOMOVE;
                    }
                }
                if (y < rctScreen.Y)
                {
                    y = rctScreen.Y;

                    if (index == 7)
                    {
                        uFlags &= ~SWP_NOMOVE;
                    }
                }
                if (x + w > rctScreen.Right)
                {
                    if (index == 7)
                    {
                        x       = rctScreen.Right - w;
                        uFlags &= ~SWP_NOMOVE;
                    }
                    else
                    {
                        w = rctScreen.Right - x;
                    }
                }
                if (y + h > rctScreen.Bottom)
                {
                    if (index == 7)
                    {
                        y       = rctScreen.Bottom - h;
                        uFlags &= ~SWP_NOMOVE;
                    }
                    else
                    {
                        h = rctScreen.Bottom - y;
                    }
                }
            }

            if (h > 150 && w > 122)
            {
                PInvoke_QTWM.SetWindowPos(hwnd, IntPtr.Zero, x, y, w, h, uFlags);

                QTWindowManager.RemoveMAXIMIZE(hwnd);
            }
        }