请帮助修复 Delphi 7中的缩放dpi错误。在这个示例中,我使用TButton和锚:=[akRight],正如你所看到的,如果窗口设置为125 dpi缩放模式,按钮文本会溢出。
我准备了一个演示示例:
1)默认比例
2)大比例(如您所见,button2已消失)
原始程式码:
Unit1.pas
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Button1: TButton;
Button2: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
end.
Unit1.dfm
object Form1: TForm1
Left = 488
Top = 196
Width = 720
Height = 511
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 432
Width = 704
Height = 41
Align = alBottom
Caption = 'Panel1'
TabOrder = 0
DesignSize = (
704
41)
object Button1: TButton
Left = 12
Top = 8
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
end
object Button2: TButton
Left = 616
Top = 8
Width = 75
Height = 25
Anchors = [akTop, akRight]
Caption = 'Button2'
TabOrder = 1
end
end
object Panel2: TPanel
Left = 0
Top = 0
Width = 704
Height = 432
Align = alClient
Caption = 'Panel2'
TabOrder = 1
end
end
3条答案
按热度按时间cnwbcb6i1#
要正确使用缩放,必须使用为此准备的环境。没有什么复杂的,字母不会缩小,一切都会正常工作。我有一个演示应用程序,它展示了如何使用缩放,如果系统的全球规模与开发愿望的规模不同,也取决于整体规模,则可以调整仅应用程序本身的规模。EXE APP DEMOscreen
kkih6yb82#
要缩放应用程序,您可以在设计时(对象检查器)将Form1.Scaled设置为False,然后在运行时使用手动设置的常数按自定义因子缩放窗体:
kiayqfof3#
我找到了一个解决办法:检测所有的TControl并重新定位它们