如何在DPI感知的win应用程序上缩放标题栏? [英] How do you scale the title bar on a DPI aware win application?

查看:592
本文介绍了如何在DPI感知的win应用程序上缩放标题栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过在清单文件中设置< dpiAware> True / PM< / dpiAware> ,我可以验证与进程资源管理器,这是确实工作或通过调用GetProcessDpiAwareness。

I am making my app dpi-aware per monitor by setting <dpiAware>True/PM</dpiAware> in the manifest file. I can verify with process explorer that this is indeed working or by calling GetProcessDpiAwareness.

这一切都正常工作,我可以在我的代码在客户端区域缩放任何东西。但是,我唯一的问题是,如果我将应用程序从系统dpi监视器拖动到非系统dpi监视器,标题栏和任何系统菜单将变得太大或太小。这不是大多数内置应用程序(例如calc,边缘浏览器等)的情况,所以必须有正确的比例。有没有人如何在MS的开发者做到了这一点?

This is all working fine and I can scale anything in the client area fine in my code. However, my only problem is that if I drag my app from a system-dpi monitor to a non-system dpi monitor, the title bar and any system menu would either become too big or too small. This isn't the case for most built-in apps (e.g. calc, edge browser, etc..) so there must be away to scale it properly. Does anyone how the devs at MS did this?

下面的截图应该更好地解释我的问题。另请注意,当缩放(96dpi)时,close,min和max按钮之间的间距是不同的。

The screenshot below should explain my problem better. Also notice, that the padding between the close, min, and max button is different when it's scaled (96dpi).

示例应用程序我添加了一个非常简单的应用程序,每个监视器DPI感知。

Sample app I'm attaching a very simple app that is per-monitor dpi aware.

推荐答案


有没有人在MS的开发者做了这个?

Does anyone how the devs at MS did this?

这有一个非常令人失望的答案。使用 Alin Constantin 的WinCheat并检查计算器的顶层窗口,我看到的窗口大小为320x576,客户端大小也是320x576。

This has a pretty disappointing answer. Using Alin Constantin's WinCheat and inspecting the top-level window of Calculator, I see a window size of 320x576, and a client size that is also 320x576.

换句话说,Microsoft通过抑制窗口的非客户端区域,将所有内容放在客户端区域中,完全避免了这个问题。

In other words, Microsoft entirely avoids the problem by suppressing the non-client area of the window, putting everything in the client area instead. Making this work well for you may involve custom drawing of the title bar.

值得注意的是,计算器和例如。 Windows资源管理器不对标题栏使用相同的颜色。计算器做自定义绘图的标题栏会解释完美。

Something worth noting is that Calculator and e.g. Windows Explorer don't use the same colour for the title bars. Calculator doing custom drawing of the title bar would explain that perfectly.

这篇关于如何在DPI感知的win应用程序上缩放标题栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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