Have you ever created, a borderless window in C#.net?
There is problem with borderless window, if you maximize it, it goes FullScreen (over the taskbar).
Here is an analyis of how to achieve maximized borderless window.
If you first set the border(anything other than FormBorderStyle.None) for the window and then set WindowState to maximize, You will get a standard maximized window, you can make it border-less there after.
private void btMaximize_Click(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;
if (this.WindowState != FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Maximized;
}
else
{
this.WindowState = FormWindowState.Normal;
}
this.FormBorderStyle = FormBorderStyle.None;
}
If you maximize a window after making it borderless it goes beyond the task-bar. You will get complete full-screen.
private void btFullscreen_Click(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
if (this.WindowState != FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Maximized;
}
else
{
this.WindowState = FormWindowState.Normal;
}
}
Thanks for the content. Really appreciable.
ReplyDeleteRegards,
http://www.richonet.com
To make a borderless windows maximized without beeing fullscreen, you may also use:
ReplyDeletemyForm.Bounds = Screen.PrimaryScreen.WorkingArea;
And restore with
this.ParentForm.Bounds = _oldBounds;
Of course, you need a Rectangle named _oldBounds somewhere in your class:
private Rectangle _oldBounds;
Just use:
ReplyDeletethis.MaximumSize = Screens.PrimaryScreen.WorkingArea.Size;