Pergunta

I am using window form with borderstyle = none. When I use the following code to maximize my window, it maximizes so that it covers the traybar.

    private void pb_max_Click(object sender, EventArgs e)
    {
        if (WindowState == FormWindowState.Maximized)
        {
            WindowState = FormWindowState.Normal;
            pb_max.Image = GomeeSoft.Properties.Resources.buttonmax;
        }
        else
        {
            WindowState = FormWindowState.Maximized;
            pb_max.Image = GomeeSoft.Properties.Resources.buttonreturn;
        }
    }

How do you maximize safely so that the frame is maximized only in the workspace?

Foi útil?

Solução

Perhaps something like this:

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

From MSDN:

The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top