Пример #1
0
        private void ExpandWindowToBothScreens(IntPtr hWnd)
        {
            Screen topScreen    = Screen.AllScreens[0];
            Screen bottomScreen = Screen.AllScreens[1];
            bool   topScreenNeedsHideTaskBar    = (topScreen.WorkingArea.Bottom != topScreen.Bounds.Bottom);
            bool   bottomScreenNeedsHideTaskBar = (bottomScreen.WorkingArea.Top != bottomScreen.Bounds.Top);

            WinAPI.RectInter newPos = new WinAPI.RectInter
            {
                left   = Math.Max(topScreen.Bounds.Left, bottomScreen.WorkingArea.Left),
                top    = 0,
                right  = Math.Min(topScreen.WorkingArea.Width, bottomScreen.WorkingArea.Right),
                bottom = (topScreenNeedsHideTaskBar ? topScreen.Bounds.Height : topScreen.WorkingArea.Height) + (bottomScreenNeedsHideTaskBar ? bottomScreen.Bounds.Height : bottomScreen.WorkingArea.Height)
            };
            if (!IsNewBorderlessWindow(hWnd))
            {
                WinAPI.AdjustWindowRectEx(ref newPos, WinAPI.GetWindowLong(hWnd, WinAPI.GWL_STYLE), false, WinAPI.GetWindowLong(hWnd, WinAPI.GWL_EXSTYLE));
            }
            newPos.top = topScreen.Bounds.Top;

            WinAPI.WINDOWPLACEMENT newPlace = new WinAPI.WINDOWPLACEMENT
            {
                showCmd          = WinAPI.SW_NORMAL,
                ptMaxPosition    = Point.Empty,
                rcNormalPosition = newPos,
                length           = Marshal.SizeOf(typeof(WinAPI.WINDOWPLACEMENT))
            };
            WinAPI.SetWindowPlacement(hWnd, ref newPlace);
        }
Пример #2
0
 private void MaximizeWindowToScreen(IntPtr hWnd, Screen screen, Rectangle wndStartPos)
 {
     WinAPI.WINDOWPLACEMENT newPlace = new WinAPI.WINDOWPLACEMENT
     {
         length           = Marshal.SizeOf(typeof(WinAPI.WINDOWPLACEMENT)),
         showCmd          = WinAPI.SW_MAXIMIZE,
         ptMaxPosition    = screen.Bounds.Location,
         rcNormalPosition = (WinAPI.RectInter)wndStartPos
     };
     WinAPI.SetWindowPlacement(hWnd, ref newPlace);
 }
Пример #3
0
 public void StartMoveOrSize(IntPtr hWnd)
 {
     WinAPI.WINDOWPLACEMENT wndPlace = new WinAPI.WINDOWPLACEMENT();
     wndPlace.length = Marshal.SizeOf(wndPlace);
     WinAPI.GetWindowPlacement(hWnd, out wndPlace);
     wndStartPos = (Rectangle)wndPlace.rcNormalPosition;
     if ((wndPlace.showCmd & WinAPI.SW_SHOWMAXIMIZED) == WinAPI.SW_SHOWMAXIMIZED)
     {
         phase     = Phase.Moving;
         movingWnd = hWnd;
         beginMoving(hWnd);
     }
     else
     {
         phase = Phase.StartMoveOrSize;
     }
 }