1

我编写了一个小型测试 VCL 应用程序,监视器 PPI 为 96。

该应用程序上有一个 TGridPanel,上面有一个绝对像素大小的列。

在该列上,我放置了一个 TComboBox 并对齐它alClient

这是 DFM 代码:

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 182
  ClientWidth = 514
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object GridPanel1: TGridPanel
    Left = 0
    Top = 0
    Width = 514
    Height = 182
    Align = alClient
    Caption = 'GridPanel1'
    ColumnCollection = <
      item
        Value = 100.000000000000000000
      end
      item
        SizeStyle = ssAbsolute
        Value = 150.000000000000000000
      end>
    ControlCollection = <
      item
        Column = 0
        Control = Button1
        Row = 0
      end
      item
        Column = 1
        Control = ComboBox1
        Row = 0
      end
      item
        Column = 0
        Control = Edit1
        Row = 1
      end>
    RowCollection = <
      item
        Value = 50.000000000000000000
      end
      item
        Value = 50.000000000000000000
      end>
    TabOrder = 0
    object Button1: TButton
      Left = 1
      Top = 1
      Width = 362
      Height = 21
      Align = alTop
      Caption = 'Button1'
      TabOrder = 0
      OnClick = Button1Click
    end
    object ComboBox1: TComboBox
      Left = 363
      Top = 1
      Width = 150
      Height = 21
      Align = alClient
      TabOrder = 1
      Text = 'ComboBox1'
    end
    object Edit1: TEdit
      Left = 1
      Top = 91
      Width = 362
      Height = 21
      Align = alTop
      TabOrder = 2
      Text = 'Edit1'
    end
  end
end

和PAS代码:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    GridPanel1: TGridPanel;
    Button1: TButton;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  PPI: Integer;
begin
  PPI := Integer.Parse(Edit1.Text);
  GridPanel1.ScaleForPPI(PPI);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  Edit1.Text := Screen.PixelsPerInch.ToString;
end;

end.

然后,我在 Windows 10 的高级缩放设置中将自定义缩放因子更改为 125。

注销并再次登录后,当我再次运行应用程序时,组合框的下拉按钮不再可见。

你如何处理这个问题?

我试图调用GridPanel1.ScaleForPPI(96)which 恢复组合框上的下拉按钮。但是,这种方式违背了 PPI 缩放的目的,不是吗?

120 PPI

96 PPI

4

1 回答 1

0

这个问题在 Delphi 10.3.1 中消失了。

所以这至少是 Delphi 10.1(以及可能的其他旧版本)中的一个错误。

于 2019-05-12T08:27:43.090 回答