如何强制窗口在调整大小时保持一定的宽度/高度比 [英] How to force a window to maintain a certain width/height ratio when resized

查看:998
本文介绍了如何强制窗口在调整大小时保持一定的宽度/高度比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的窗口总是保持一定的比例,让我们说1.33333333。所以,如果窗口是 width = 800,height = 600 ,用户将宽度更改为600,我想自动将高度更改为450.

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.

我已经截获 WM_SIZE ,但我不知道它是否足够;

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.

推荐答案

WM_SIZING 在用户调整窗口大小时发送到窗口。

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

而是处理 WM_WINDOWPOSCHANGING - 这是当代码(或用户)改变窗口大小时将由内部SetWindowPos函数发送,并且将确保甚至tile&级联操作遵守您的尺寸策略。

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.

这篇关于如何强制窗口在调整大小时保持一定的宽度/高度比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆