简体   繁体   English

如何在调整大小时强制窗口保持一定的宽度/高度比

[英]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_SIZINGhttp//msdn.microsoft.com/en-us/library/ms632647.aspx

Processing this message allows you to change resulting window size. 处理此消息允许您更改生成的窗口大小。

Try the Resize event. 尝试调整大小事件。 There is an example of how to maintain a desired aspect ration in the link. 有一个例子说明如何在链接中保持所需的宽高比。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 手动调整窗口大小后,QGraphicsScene宽度/高度未更改 - QGraphicsScene width/height is not changing after the window was resized manually gnuplot x11 terminal - 在调整窗口大小时,宽高比不会保持不变 - gnuplot x11 terminal - aspect ratio does not remain constant when window is resized wxpython如何在调整窗口大小时防止BoxSizer崩溃? - wxpython How to prevent BoxSizer from collapsing when window is resized? 调整列表视图大小时,如何设置标题宽度等于其列表视图控件宽度? - How to set header width equal to its list view control width when list view is resized? SDL2:调整窗口大小时如何保持宽高比 - SDL2: How to keep aspect ratio when resizing the window C ++如何获取窗口大小(宽度和高度)? - C++ How to get the window size (width and height)? 如何从 CreateWindowEx() window 获取宽度和高度? C++ - How to get width and height from CreateWindowEx() window? C++ Qt防止控件在调整窗口大小时移动 - Qt prevent controls moving when window resized 我如何获得一个窗口来调整大小的C ++时保留绘制的对象 - How do I get a Window to keep the painted objects when it is resized C++ 如何在不同线程中保持一定的帧率 - How to maintain certain frame rate in different threads
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM