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 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); } }
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); } } }
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); } }