Beispiel #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);
        }
Beispiel #2
0
        private void BeginMovingWindow(IntPtr hWnd)
        {
            Debug.Assert(dropBar == null);

            uint style          = WinAPI.GetWindowLong(hWnd, WinAPI.GWL_STYLE);
            bool canBeMaximized = ((style & WinAPI.WS_MAXIMIZEBOX) == WinAPI.WS_MAXIMIZEBOX) || ((style & WinAPI.WS_SIZEBOX) == WinAPI.WS_SIZEBOX);

            if (canBeMaximized)
            {
                DropBar.WindowPosType windowPos = (Screen.FromHandle(hWnd).Primary ? DropBar.WindowPosType.OnTop : DropBar.WindowPosType.OnBottom);
                dropBar = new DropBar(windowPos);
                dropBar.Show();
            }
        }
Beispiel #3
0
        private void ExpandWindowToHalfScreen(IntPtr hWnd, Screen screen, bool toLeft)
        {
            //Note: should use Aero Snap, but there is no API for it...
            Rectangle screenArea = screen.WorkingArea;

            WinAPI.RectInter newPos = new WinAPI.RectInter();
            if (toLeft)
            {
                newPos.left = screenArea.Left; newPos.right = screenArea.Right / 2;
            }
            else
            {
                newPos.left = screenArea.Left + screenArea.Right / 2; newPos.right = screenArea.Right;
            }
            newPos.top = screenArea.Top; newPos.bottom = screenArea.Bottom;
            WinAPI.AdjustWindowRectEx(ref newPos, WinAPI.GetWindowLong(hWnd, WinAPI.GWL_STYLE), false, WinAPI.GetWindowLong(hWnd, WinAPI.GWL_EXSTYLE));
            newPos.bottom--;
            WinAPI.SetWindowPos(hWnd, IntPtr.Zero, newPos.left, screenArea.Top, newPos.right - newPos.left, newPos.bottom - screenArea.Top, WinAPI.SWP_ASYNCWINDOWPOS | WinAPI.SWP_NOZORDER);
        }