6

I want my window to always maintain a certain ratio of let's say 1.33333333. So, if the window is width = 800, height = 600 and the user changes the width to 600, I want to change the height to 450 automatically.

I'm already intercepting WM_SIZE but I don't know if it's enough; also I don't know how to change the width or height to maintain my ratio.

Péter Török
  • 114,404
  • 31
  • 268
  • 329
woor
  • 63
  • 1
  • 3
  • Slightly different question, but generally the same answer as: http://stackoverflow.com/questions/2406168/constraining-window-position-to-desktop-working-area – Adrian McCarthy Mar 15 '10 at 17:07

3 Answers3

9

WM_SIZING is sent to the window while the user is resizing the window.

Rather handle WM_WINDOWPOSCHANGING - this is sent by the internal SetWindowPos function when code (or the user) changes the window size and will ensure that even tile & cascade operations obey your sizing policy.

Chris Becke
  • 34,244
  • 12
  • 79
  • 148
3

See WM_SIZING: http://msdn.microsoft.com/en-us/library/ms632647.aspx

Processing this message allows you to change resulting window size.

Janusz Lenar
  • 1,690
  • 2
  • 13
  • 19
-1

Try the Resize event. There is an example of how to maintain a desired aspect ration in the link.

Mike Marshall
  • 7,788
  • 4
  • 39
  • 63