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).
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.
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().
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).
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