Example #1
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 #2
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;
        }
Example #3
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;
        }
        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);
        }
Example #5
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;
                    }
                }
            }
        }
        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);
            }
        }