如何缩放窗口 [英] How to scale a window

查看:122
本文介绍了如何缩放窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想支持高清显示器而无需用户更改系统DPI设置。为此,即使系统DPI未设置为100%以上,我也希望缩放/缩放窗口。显然,当DPI设置
高于100%时,操作系统可以缩放窗口。是否有公开的API可以让我传递"DPI比例因子"。当DPI设置高于100%时,窗口是否缩放?对于我控制下的对话框,我通过在每个子窗口上设置缩放的
字体,然后在显示之前缩放对话框和每个控件(在OnInitDialog中)取得了一些成功。然而,操作系统暴露了"共同对话框"。例如文件打开,更难以及时拦截以扩展它们。是否有
任何可以提供帮助的API?例如,是否可以临时为我的进程设置DPI设置,创建对话框,然后重置DPI以欺骗系统为我进行缩放?



R.D。 Holland

I want to support HD monitors without the user having to change the system DPI setting. To do so, I would like to scale/zoom a window even when the system DPI is not set above 100%. Obviously the OS has the capability to scale a window when the DPI setting is above 100%. Is there an API publically available that would let me pass in a "DPI scale factor" and have the window scaled like it is when the DPI setting is above 100%? For dialogs under my control, I have had some success by setting a scaled font on each child window and then scaling the dialog and each control before it is displayed (in OnInitDialog). However, the OS exposes "common dialogs" such as file open that are more difficult to intercept in time to scale them. Is there any APIs that can help out? For example, is it possible to temporarily set the DPI setting for my process, create the dialog, and then reset the DPI to trick the system into doing the scaling for me?


R.D. Holland

推荐答案

嗨RD Holland,

Hi RD Holland,

我找不到API可以帮助你这样做暂时设置DPI设置。

I cannot find a API could help you doing this temporarily set the DPI setting.

DPI设置应在regstry中注册,例如:

The DPI setting should registered in the regstry, for example:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft \ Windows NT \ CurrentVersion \FontDPI

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI

如果您暂时设置了DPI设置,也许您可​​以修改注册表并将其更改回来。

Maybe you could modify the registry and change it back if you finished temporarily set the DPI setting.

祝你好运,

Shu


这篇关于如何缩放窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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