Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically Maximize Window On Half Of Screen

I want to maximize a random window on the left side of my screen. Can I use Windows Aero functions from my code ? This window can be maximized like that with the mouse. I just want to do that programmatically.

I use C# and I can get the IntPtr of the window.

If possible without faking mouse or keyboard input.

like image 259
Bitterblue Avatar asked Aug 19 '13 12:08

Bitterblue


1 Answers

This can be done without p/invoke.

Try this:

Rectangle rect = Screen.PrimaryScreen.WorkingArea;
rect.Width = rect.Width / 2;
Bounds = rect;

This will put the current window on the left of the primary screen.

Then just add this to put it on the right of the screen.

Location = new Point(rect.Width, 0);
like image 104
Nicolas Tyler Avatar answered Oct 23 '22 00:10

Nicolas Tyler