Is there a way to control what space of the screen windows can be maximized to, in C#
To limit the size of your application's window, use the Form.MaximizedBounds property. You can use the Screen class to get the bounds of your current (or some other) screen.
For example, this will maximize your form to left half of the primary screen:
public partial class MyForm : Form
{
public MyForm()
{
InitializeComponent();
// set width to 1/2 of screen
Rectangle screenBounds = Screen.PrimaryScreen.Bounds;
screenBounds.Width = screenBounds.Width / 2;
this.MaximizedBounds = screenBounds;
// maximize
this.WindowState = FormWindowState.Maximized;
}
}
[Edit]
If you want to dock your window to one side of the screen and limit the remaining desktop area for other applications, you might be interested in registering a custom APPBAR through Windows API.
Check the following links:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With