有没有win32窗口自适应高DPI的好方法?

蠓虫带着秤砣飞 2021-03-11 02:52:57
查到了SetProcessDpiAwareness这个函数的三个参数

PROCESS_DPI_UNAWARE DPI unaware. This app does not scale for DPI changes and is always assumed to have a scale factor of 100% (96 DPI). It will be automatically scaled by the system on any other DPI setting.
这个我以为会DWM会帮我放大,发现不行。

PROCESS_SYSTEM_DPI_AWARE System DPI aware. This app does not scale for DPI changes. It will query for the DPI once and use that value for the lifetime of the app. If the DPI changes, the app will not adjust to the new DPI value. It will be automatically scaled up or down by the system when the DPI changes from the system value.
这个是应用启动阶段获取dpi,但是dpi改变后不会通知到软件。总的来说还是靠软件自己解决。

PROCESS_PER_MONITOR_DPI_AWARE Per monitor DPI aware. This app checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes. These applications are not automatically scaled by the system.
dpi改变后会通知到软件,但是需要软件自己解决。
...全文
714 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
叶恭介叶恭介 2021-03-18
  • 打赏
  • 举报
回复
引用 4 楼 凌乱哥 的回复:
我之前是在项目属性里把DPI设为“无”来处理的
跟你一样是这么做。
凌乱哥 2021-03-16
  • 打赏
  • 举报
回复
我之前是在项目属性里把DPI设为“无”来处理的
  • 打赏
  • 举报
回复
引用 2 楼 zgl7903 的回复:
缩放比例 = (double)GetDeviceCaps(LOGPIXELSX) / 96.0 * 100.0
图片paddding文字padding之类的细节。 控件padding inset
zgl7903 2021-03-13
  • 打赏
  • 举报
回复
缩放比例 = (double)GetDeviceCaps(LOGPIXELSX) / 96.0 * 100.0
  • 打赏
  • 举报
回复
问题解决。散分吧。

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧