Maximized screen ignores taskbar

前端 未结 8 1728
刺人心
刺人心 2020-12-20 16:53

I have a form I set to Maximized, but for some reason it\'s ignoring the taskbar and maximizing to the entire screen. Is that typical? Is there a workaround?

相关标签:
8条回答
  • 2020-12-20 17:03

    One thing I left out of the description--I'd turned off the maximize button. When I tested turning that property back on, the task bar showed up again. Apparently it assumes if you don't want a maximize button you are creating a kiosk-style application where you don't want your users to see anything but the application screen. Not exactly what I'd expect, but works I guess.

    I had this problem and solved it by Jeff's help. First, set the windowstate to Maximized. but Do not disable the MaximizeBox. Then if you want MaximizeBox to be disabled you should do it programmatically:

    private void frmMain_Load(object sender, EventArgs e)
    {
       this.MaximizeBox = false;
    }
    
    0 讨论(0)
  • 2020-12-20 17:05

    If you don't want to re-enable the maximize button, you could manually set the size of the window :

    private void Maximize()
    {
        Screen screen = Screen.FromPoint(this.Location);
        this.Size = screen.WorkingArea.Size;
        this.Location = Point.Empty;
    }
    

    (WorkingArea is the area of the screen that can be used by applications, excluding the TaskBar and other toolbars)

    0 讨论(0)
  • 2020-12-20 17:07

    If you are using FormBorderStyle.None then it is very simple to make sure it doesn't cover the taskbar when maximized:

    this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size;
    

    It will probably work for other border styles and is probably the cleanest way to ensure your form does not cover the taskbar.

    0 讨论(0)
  • 2020-12-20 17:09

    When you set the form border style to none the form will hide the taskbar. To get around this you have to set the the MaximumSize of the form manually. If windows auto-hides the taskbar the form will cover even the hidden taskbar! To get around this reduce the max size height by one pixel (if your taskbar is in the bottom)!

            Me.MaximumSize = New Size(My.Computer.Screen.WorkingArea.Size.Width, _
                                      My.Computer.Screen.WorkingArea.Size.Height - 1)
    
    0 讨论(0)
  • 2020-12-20 17:13

    Taskbar can be docked at left, top, bottom, right side. If you want maximized window without overlayed taskbar, use this code:

    
    ...cut...
      public partial class Form2 : Form
        {
            public Form2()
            {
              // set default start position to manual  
              this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; 
    
    
              // set position and size to the Form.  
              this.Bounds = Screen.PrimaryScreen.WorkingArea; 
    
    
          ....
              InitializeComponent();
            }
    
    ...cut...
    
    0 讨论(0)
  • 2020-12-20 17:14

    Set the form border to None before making it maximized.

    This code will work in a single monitor:

    private void Form1_Load(object sender, EventArgs e)
    {
        this.FormBorderStyle = FormBorderStyle.None;
        this.WindowState = FormWindowState.Maximized;
    }
    

    I haven't tested the dual monitor scenario since i don't have this at this moment. :P

    EDIT: I didn't get it "Maximized Screen Ignores Taskbar". What does Ignores mean?

    Do you want your form to cover the taskbar and fill the entire screen?

    0 讨论(0)
提交回复
热议问题