0

I have a problem with multimonitor system and maximizing my borderless C# Winform window. I'd like the form cover two screens, but it only cover the primary screen.

        Screen[] screens = Screen.AllScreens;    
        int height = 0;
        int width = 0;
        foreach (Screen screen in screens)
        {
            //take smallest height
            height = (screen.Bounds.Height >= height) ? screen.Bounds.Height : height;
            width += screen.Bounds.Width;
        }

        Size = new System.Drawing.Size(width, height);

        WindowState = FormWindowState.Maximized;
        FormBorderStyle = FormBorderStyle.None;
Dante Jiang
  • 177
  • 1
  • 13
  • Are both monitors using the same resolution? Are both, for example, working on landscape mode? I'm asking this since I'm using 2 monitors: 1 working on vertical mode and another one on landscape. What is supposed to happen when I maximize a window? The form layout is going to get broken, that's why it's just maximizing just on one screen. – Gonzo345 Jun 21 '18 at 09:08
  • Yes ,the same resolution and working in Extend mode. – Dante Jiang Jun 21 '18 at 09:12
  • I haven't tried this solution, but noting my previous comment, I found this, suggesting you to create your own "maximize" https://stackoverflow.com/a/5015350/3563910 having your expected behavior – Gonzo345 Jun 21 '18 at 09:12
  • But I 'd like to cover the taskbar too. – Dante Jiang Jun 21 '18 at 09:29
  • So I guess you have to use the full screen resolution... right? – Gonzo345 Jun 21 '18 at 09:30
  • seems the `screen.Bounds.Height` is less than the true heigt of the display area. – Dante Jiang Jun 21 '18 at 09:31
  • When `WindowState` is Maximized, Windows does not respect the `Size` property you set. So you need to use the `Normal` state, and set the window's start position to the upper-left corner of the primary screen. – kennyzx Jun 21 '18 at 09:35
  • I'm about 97.32% sure that this can't be done. Look at [this Q+A](https://stackoverflow.com/q/3361211/17034), shows you how to intercept the maximize command. So you can resize the window yourself instead of actually maximizing it. – Hans Passant Jun 21 '18 at 11:46

0 Answers0