DPI处理和标准对话框

DPI处理和标准对话框

本文介绍了Windows 10 DPI处理和标准对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在修改我的应用程序以支持高DPI值(高于100%/ 96dpi)。

I am modifying my application to support high-DPI values (above 100%/96dpi).

我修改了应用程序的清单文件,包括:

I modified the application's manifest file to include:

<dpiAware>true/PM</dpiAware>

我能够处理自己应用程序表单的所有DPI缩放比例,但如何处理标准Windows对话框(字体选择器,打开文件,文件夹浏览器等)通过WinAPI。有没有一种方法可以手动通知窗口,我只希望这些对话框自动为更高的DPI缩放?

I am able to handle all the DPI scaling for my own app's forms, but how do I handle standard windows dialogs (Font selector, open files, folder browser, etc) through WinAPI. Is there a way to manually inform windows that I want only these dialogs automatically scaled for the higher DPI?

*更新*

使用 SetThreadDpiAwarenessContext WinAPI函数后,Windows似乎可以处理缩放,但是它是通过缩放图像(模糊文本)而不是缩放控件(记住,这些是标准的Windows控件,例如通过调用 GetOpenFileNameW生成的控件。)

After using the "SetThreadDpiAwarenessContext" WinAPI function, windows does seem to handle the scaling, but it does so in the by scaling the image (blurred text) instead of scaling the controls (remember, these are standard windows controls like the ones generated by calling "GetOpenFileNameW").

有什么想法可以使Windows绘制正确缩放的打开文件对话框而不模糊文本?

Any ideas how to get windows to draw the open-file dialog properly scaled without blurred text?

推荐答案

感谢@ zett42,为将来的访问者总结链接的答案,赢得10 Aniv。该版本引入了新的 SetThreadDpiAwarenessContext()函数来设置每个线程的DPI感知,允许您从单独的线程打开标准的Windows对话框,并使Windows DPI设置自动处理对话框的缩放。

Thank you @zett42, to sum up the linked answer for future visitors, Win 10 Aniv. edition introduced a new "SetThreadDpiAwarenessContext()" function to set a per-thread DPI awareness, allowing you to open standard windows dialogs from a separate thread and have the Windows DPI setting automatically handle scaling on the dialog.

这篇关于Windows 10 DPI处理和标准对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 14:33