[英]How to force a window to maintain a certain width/height ratio when resized
I want my window to always maintain a certain ratio of let's say 1.33333333. 我希望我的窗口始终保持一定的比例,比方说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. 因此,如果窗口width = 800, height = 600
并且用户将宽度更改为600,我想自动将高度更改为450。
I'm already intercepting WM_SIZE
but I don't know if it's enough; 我已经拦截了WM_SIZE
但我不知道它是否足够; also I don't know how to change the width or height to maintain my ratio. 我也不知道如何改变宽度或高度以保持我的比例。
WM_SIZING is sent to the window while the user is resizing the window. 当用户调整窗口大小时, WM_SIZING被发送到窗口。
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. 而是处理WM_WINDOWPOSCHANGING - 这是由内部SetWindowPos函数在代码(或用户)更改窗口大小时发送的,并确保偶数tile和cascade操作遵循您的大小调整策略。
See WM_SIZING
: http://msdn.microsoft.com/en-us/library/ms632647.aspx 请参阅WM_SIZING
: http : //msdn.microsoft.com/en-us/library/ms632647.aspx
Processing this message allows you to change resulting window size. 处理此消息允许您更改生成的窗口大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.