Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you programmatically resize and move windows with the Windows API?

Tags:

windows

winapi

How do you programmatically resize and move windows with Windows API?

The scenario is: I want to vertically tile two windows (80%/20% width proportions).

like image 460
Daniel Silveira Avatar asked Mar 28 '09 13:03

Daniel Silveira


People also ask

How can you size resize and move windows?

Press Alt + F7 to move a window or Alt + F8 to resize. Use the arrow keys to move or resize, then press Enter to finish, or press Esc to return to the original position and size.


2 Answers

For flicker-free, simultaneously positioning two (or more) windows, your best bet is to use BeginDeferWindowPos(), DeferWindowPos() and EndDeferWindowPos(). In your case, since you're moving two at the same time, this is your best bet.

Three older, simpler functions you might also consider are SetWindowPos(), MoveWindow() and AdjustWindowRectEx().

like image 162
mghie Avatar answered Oct 09 '22 15:10

mghie


Use SetWindowPos() in the Windows API.

Given a HWND, you can change the z-order, position (upper left), size, as well as numerous other flags (like showing or hiding, making it the active window or not, etc).

like image 32
Reed Copsey Avatar answered Oct 09 '22 13:10

Reed Copsey