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

前端 未结 5 1725
刺人心
刺人心 2020-12-03 04:52

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

相关标签:
5条回答
  • 2020-12-03 05:20

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

    0 讨论(0)
  • 2020-12-03 05:20

    Look up MoveWindow in your SDK documentation.

    0 讨论(0)
  • 2020-12-03 05:22

    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?

    0 讨论(0)
  • 2020-12-03 05:31

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

    0 讨论(0)
  • 2020-12-03 05:32

    SetWindowPos or MoveWindow will accomplish this for you

    0 讨论(0)
提交回复
热议问题