private void MaxMinWindow(int index)
        {
            //const int SW_MAXIMIZE = 3;
            //const int SW_MINIMIZE = 6;
            const int SW_RESTORE       = 9;
            const int SW_SHOWMINIMIZED = 2;
            const int SW_SHOWMAXIMIZED = 3;

            IntPtr hwnd = pluginServer.ExplorerHandle;

            if (hwnd != IntPtr.Zero)
            {
                int nCmdShow;
                switch (index)
                {
                case 13:
                    // Minimize
                    nCmdShow = SW_SHOWMINIMIZED;
                    break;

                case 14:
                    // Restore
                    nCmdShow = SW_RESTORE;
                    break;

                default:        //12
                    // Maximize
                    nCmdShow = SW_SHOWMAXIMIZED;
                    break;
                }

                PInvoke_QTWM.ShowWindow(hwnd, nCmdShow);
            }
        }
Example #2
0
        private void buttonGetCurSize_Click(object sender, EventArgs e)
        {
            RECT rct;

            PInvoke_QTWM.GetWindowRect(this.hwndExplorer, out rct);

            this.nudInitialW.Value = rct.Width;
            this.nudInitialH.Value = rct.Height;
        }
Example #3
0
        private void buttonGetCurLoc_Click(object sender, EventArgs e)
        {
            RECT rct;

            PInvoke_QTWM.GetWindowRect(this.hwndExplorer, out rct);

            this.nudInitialX.Value = rct.left;
            this.nudInitialY.Value = rct.top;
        }
        private List <IntPtr> EnumExplorer(bool fExcludeCurrent)
        {
            lstExploererHwnd = new List <IntPtr>();

            PInvoke_QTWM.EnumWindows(
                EnumExplorerCallback,
                fExcludeCurrent ? pluginServer.ExplorerHandle : IntPtr.Zero);

            return(lstExploererHwnd);
        }
Example #5
0
        private List <IntPtr> EnumExplorer(bool fExcludeCurrent)
        {
            this.lstExploererHwnd = new List <IntPtr>();

            PInvoke_QTWM.EnumWindows(
                new EnumWndProc(this.EnumExplorerCallback),
                fExcludeCurrent ? this.pluginServer.ExplorerHandle : IntPtr.Zero);

            return(this.lstExploererHwnd);
        }
Example #6
0
        private void buttonGetCurrentToPreset_Click(object sender, EventArgs e)
        {
            RECT rct;

            PInvoke_QTWM.GetWindowRect(this.hwndExplorer, out rct);

            this.nudPresets_X.Value = rct.left;
            this.nudPresets_Y.Value = rct.top;
            this.nudPresets_W.Value = rct.Width;
            this.nudPresets_H.Value = rct.Height;
        }
Example #7
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);
            }
        }
Example #8
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);
            }
        }
        private bool EnumExplorerCallback(IntPtr hwnd, IntPtr lParam)
        {
            StringBuilder sb = new StringBuilder(260);

            PInvoke_QTWM.GetClassName(hwnd, sb, 260);

            string className = sb.ToString();

            if (lParam != hwnd && (className == CN_CabinetWClass || className == CN_Explorer))
            {
                lstExploererHwnd.Add(hwnd);
            }

            return(true);
        }
        private void DoPresetsCore(Rectangle rct)
        {
            IntPtr hwnd = 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);
                RemoveMAXIMIZE(hwnd);
            }
        }
        private void MoveWindow(int index)
        {
            IntPtr hwnd = 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 -= ResizeDelta;
                break;

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

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

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

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

            RemoveMAXIMIZE(hwnd);
        }
        private void RestoreInitialSize()
        {
            bool fLoc    = (ConfigValues[0] & 0x20) != 0;
            bool fSiz    = (ConfigValues[0] & 0x80) != 0;
            bool fPreset = (ConfigValues[0] & 0x10) != 0;

            if (fLoc || fSiz || fPreset)
            {
                IntPtr hwnd = 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(startingPreset) && dicPresets.ContainsKey(startingPreset))
                        {
                            Rectangle rctPreset = dicPresets[startingPreset];
                            PInvoke_QTWM.SetWindowPos(hwnd, IntPtr.Zero, rctPreset.X, rctPreset.Y, rctPreset.Width, rctPreset.Height, SWP_NOZORDER);
                            RemoveMAXIMIZE(hwnd);
                        }
                        return;
                    }

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

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

                    RemoveMAXIMIZE(hwnd);
                }
            }
        }
Example #13
0
        public SettingWindow(Rectangle rctInitial, byte[] config, int delta_RESIZE, IntPtr hwnd, Dictionary <string, Rectangle> dicPresets, string startingPreset)
        {
            InitializeComponent();


            if (System.Globalization.CultureInfo.CurrentCulture.Parent.Name == "ja")
            {
                string[] strs = Resource.ResStrs_Options_ja.Split(new char[] { ';' });

                this.chbInitialSize.Text           = strs[0];
                this.chbInitialLoc.Text            = strs[1];
                this.buttonRestoreSize.Text        = strs[2];
                this.buttonRestoreLoc.Text         = strs[3];
                this.checkBoxResizeMode.Text       = strs[4];
                this.labelDELTARESIZE.Text         = strs[5];
                this.groupBoxPresets.Text          = strs[6];
                this.buttonSet.Text                = strs[7];
                this.buttonDel.Text                = strs[8];
                this.buttonOK.Text                 = strs[9];
                this.buttonCancel.Text             = strs[10];
                this.buttonGetCurLoc.Text          = strs[11];
                this.buttonGetCurSize.Text         = strs[12];
                this.chbStartingPreset.Text        = strs[13];
                this.buttonGetCurrentToPreset.Text = strs[14];
            }


            this.hwndExplorer   = hwnd;
            this.dicPresets     = new Dictionary <string, Rectangle>(dicPresets);
            this.startingPreset = startingPreset;

            Rectangle rctScreen = Screen.FromHandle(hwnd).Bounds;

            this.nudInitialW.Maximum = rctScreen.Width;
            this.nudInitialH.Maximum = rctScreen.Height;

            RECT rct;

            PInvoke_QTWM.GetWindowRect(hwnd, out rct);
            this.Text += " ( " + rct.left + ", " + rct.top + " )  " + rct.Width + " x " + rct.Height;

            try {
                if ((config[0] & 0x80) != 0)
                {
                    this.chbInitialSize.Checked = true;
                }

                if ((config[0] & 0x40) != 0)
                {
                    this.checkBoxResizeMode.Checked = false;
                }

                if ((config[0] & 0x20) != 0)
                {
                    this.chbInitialLoc.Checked = true;
                }

                if ((config[0] & 0x10) != 0)
                {
                    this.chbStartingPreset.Checked = true;
                }

                if ((config[0] & 0x08) != 0)
                {
                    this.chbRestoreClosedRct.Checked = true;
                }


                this.nudInitialX.Value = rctInitial.X;
                this.nudInitialY.Value = rctInitial.Y;
                this.nudInitialW.Value = rctInitial.Width;
                this.nudInitialH.Value = rctInitial.Height;

                if (delta_RESIZE < 33 && delta_RESIZE > 0)
                {
                    this.nudDelta.Value = delta_RESIZE;
                }

                this.chbInitialLoc_CheckedChanged(null, EventArgs.Empty);
                this.chbInitialSize_CheckedChanged(null, EventArgs.Empty);

                if (this.chbStartingPreset.Checked)
                {
                    this.nudInitialX.Enabled               = this.nudInitialY.Enabled = this.chbInitialLoc.Enabled =
                        this.buttonRestoreLoc.Enabled      = this.buttonGetCurLoc.Enabled =
                            this.buttonRestoreSize.Enabled = this.buttonGetCurSize.Enabled =
                                this.nudInitialW.Enabled   = this.nudInitialH.Enabled = this.chbInitialSize.Enabled = false;
                }
                else
                {
                    this.comboBox2.Enabled = false;
                }
            }
            catch {
            }

            foreach (string name in this.dicPresets.Keys)
            {
                this.comboBox1.Items.Add(name);
                this.comboBox2.Items.Add(name);
            }

            if (this.startingPreset != null && this.startingPreset.Length > 0)
            {
                int indexStartingPreset = this.comboBox2.Items.IndexOf(this.startingPreset);
                if (indexStartingPreset != -1)
                {
                    this.comboBox2.SelectedIndex = indexStartingPreset;
                }
            }

            if (this.comboBox1.Items.Count > 0)
            {
                this.comboBox1.SelectedIndex = 0;
            }
        }
        private void TileExplorers()
        {
            IntPtr        hwndCurrent = pluginServer.ExplorerHandle;
            List <IntPtr> hwnds       = EnumExplorer(false);
            int           c           = hwnds.Count;

            if (c > 1)
            {
                if (!fNowTiled)
                {
                    RECT rctCurrentWindow;
                    PInvoke_QTWM.GetWindowRect(hwndCurrent, out rctCurrentWindow);
                    Rectangle rctCurrentScreen = Screen.FromPoint(new Point(rctCurrentWindow.left, rctCurrentWindow.top)).WorkingArea;

                    List <IntPtr>  lstFillingHWNDs = new List <IntPtr>();
                    Queue <IntPtr> qHwnds          = new Queue <IntPtr>(hwnds);

                    dicTiledRectangle = new Dictionary <IntPtr, RECT>();

                    if (!fFillAllScreen)
                    {
                        int w = rctCurrentScreen.Width / windowColumnLength;
                        int h = rctCurrentScreen.Height / windowRowLength;

                        int remain = c % windowColumnLength;
                        if (remain > 0)
                        {
                            for (int i = 0; i < remain; i++)
                            {
                                lstFillingHWNDs.Add(qHwnds.Dequeue());
                            }
                        }

                        int  x     = 0;
                        int  y     = 0;
                        uint uFlag = SWP_NOZORDER | SWP_NOACTIVATE;

                        if (lstFillingHWNDs.Count > 0)
                        {
                            // Set position of left column
                            int hFilling = rctCurrentScreen.Height / lstFillingHWNDs.Count;
                            foreach (IntPtr hwnd in lstFillingHWNDs)
                            {
                                RECT rctTMP;
                                PInvoke_QTWM.GetWindowRect(hwnd, out rctTMP);
                                dicTiledRectangle[hwnd] = rctTMP;

                                PInvoke_QTWM.SetWindowPos(hwnd, IntPtr.Zero, 0, y, w, hFilling, hwnd == hwndCurrent ? SWP_NOZORDER : uFlag);
                                y += hFilling;
                            }
                            x = w;
                            y = 0;
                        }

                        // Set others
                        foreach (IntPtr hwnd in qHwnds)
                        {
                            RECT rctTMP;
                            PInvoke_QTWM.GetWindowRect(hwnd, out rctTMP);
                            dicTiledRectangle[hwnd] = rctTMP;

                            PInvoke_QTWM.SetWindowPos(hwnd, IntPtr.Zero, x, y, w, h, hwnd == hwndCurrent ? SWP_NOZORDER : uFlag);

                            y += h;
                            if (y + h > rctCurrentScreen.Bottom)
                            {
                                y  = 0;
                                x += w;
                            }
                        }
                        fNowTiled = true;
                    }
                }
                else
                {
                    if (dicTiledRectangle != null)
                    {
                        uint uFlag = SWP_NOZORDER | SWP_NOACTIVATE;

                        foreach (IntPtr hwnd in dicTiledRectangle.Keys)
                        {
                            RECT rct = dicTiledRectangle[hwnd];

                            PInvoke_QTWM.SetWindowPos(hwnd, IntPtr.Zero, rct.left, rct.top, rct.Width, rct.Height, hwnd == hwndCurrent ? SWP_NOZORDER : uFlag);
                        }

                        dicTiledRectangle.Clear();
                        fNowTiled = false;
                    }
                }
            }
        }
 internal static void RemoveMAXIMIZE(IntPtr hwnd)
 {
     PInvoke_QTWM.SetWindowLongPtr(hwnd, -16, PInvoke_QTWM.Ptr_OP_AND(PInvoke_QTWM.GetWindowLongPtr(hwnd, -16), ~WS_MAXIMIZE));
 }
        private void ResizeWindow(int index)
        {
            IntPtr hwnd = pluginServer.ExplorerHandle;

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

            RECT rct;

            PInvoke_QTWM.GetWindowRect(hwnd, out rct);

            bool fAuto = (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 -= ResizeDelta;
                    y -= ResizeDelta;
                    w += ResizeDelta * 2;
                    h += ResizeDelta * 2;
                }
                else
                {
                    w      += ResizeDelta;
                    h      += ResizeDelta;
                    uFlags |= SWP_NOMOVE;
                }
                break;

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

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

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

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

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

            case 7:
                //Restore size
                w       = sizeInitial.Width;
                h       = 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);

                RemoveMAXIMIZE(hwnd);
            }
        }