在 Delphi 中获取自定义 DPI 百分比 [英] Getting custom DPI percentage in Delphi

查看:12
本文介绍了在 Delphi 中获取自定义 DPI 百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 Windows 7 中以高 DPI 模式让我的 Delphi 2010 应用程序更加用户友好我一直在尝试几种方法来检索 PixelsPerInch 并与 96 进行比较.唉,无论我尝试什么,我总是得到 96.我的问题是:

Trying to my Delphi 2010 application more user freindly in high DPI modes in Windows 7 I have been trying several methods to retrive PixelsPerInch and compare to 96. Alas, no matter what I tried I always get 96. My questions are:

  1. 获得自定义 DPI 模式的最佳做法是什么?
  2. 不管我的分数是多少,我得到一个恒定的 96 是否意味着我错过了什么?

这是我尝试过的

dpiX := Form1.PixelsPerInch

dpiX := Screen.PixelsPerInch

最后:

D2DFactoryOptions.DebugLevel := D2D1_DEBUG_LEVEL_NONE;
pD2DFactoryOptions := @D2DFactoryOptions;
if D2D1CreateFactory(
    D2D1_FACTORY_TYPE_SINGLE_THREADED,
    IID_ID2D1Factory,
    PD2DFactoryOptions,
    D2DFactory
    ) <> S_OK then exit;
D2DFactory.GetDesktopDpi(dpiX, dpiY)

想猜吗?没错,dpiX 在 100%、125% 和 150% 中是一个常数 96

Care to guess? that's right dpiX is a constant 96 in 100%, 125% and 150%

请指教.

推荐答案

我认为您需要通过在应用程序清单中包含以下内容来将您的应用程序标记为高 DPI 感知:

I think you need to mark your application as being high DPI aware by including this in your application manifest:

<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
    <dpiAware>true</dpiAware>
  </asmv3:windowsSettings>
</asmv3:application>

提供了关于声明 DPI 意识的详细信息 这里.

Details on declaring DPI awareness are given here.

您目前似乎正在回退到所谓的 DPI 虚拟化.

It seems like you are currently falling back to what is called DPI Virtualization.

这篇关于在 Delphi 中获取自定义 DPI 百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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