Programmatically enlarge the window half the screen

I want to enlarge a random window on the left side of the screen. Can I use Windows Aero features from my code? This window can be maximally the same as with the mouse. I just want to do this programmatically.

I am using C# and I can get IntPtr windows.

If possible, without faking a mouse or typing a keyboard.

+7
c # windows winapi aero
source share
3 answers

This is not exactly the same, but fakes it well:

 ShowWindow(handle, SW_MAXIMIZE); // for a split second you might see a maximized window here MoveWindow(handle, 0, 0, Screen.PrimaryScreen.WorkingArea.Width / 2, Screen.PrimaryScreen.WorkingArea.Height, true); 
+3
source share

This can be done without p / invoke.

Try the following:

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

This will place the current window to the left of the main screen.

Then just add this to place it to the right of the screen.

 Location = new Point(rect.Width, 0); 
+5
source share

It takes hard work to post in real time, especially for non-child processes. An example is www.ishadow.com/vdm. For manual "fixing" the maximum position of the MoveWindow window (hWnd, startPos, 0, winWidth, winHeight, true) after ShowWindow (hWnd, SW_MAXIMIZE) usually (try the task manager in Windows 10) works as described above.

0
source share

All Articles