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.
質問
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?
解決
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.