tags:

views:

1118

answers:

5

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

+9  A: 

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

Reed Copsey
+1  A: 

Look up MoveWindow in your SDK documentation.

anon
+1  A: 

SetWindowPos or MoveWindow will accomplish this for you

Net Citizen
+1  A: 

You're looking for one of SetWindowPos, MoveWindow and AdjustWindowRectEx.

Can you be more specific about the scenario so that we can recomend the most appropriate API?

JaredPar
+8  A: 

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 best.

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

mghie
+1 - These are other great options!
Reed Copsey