Пример #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);
 }