我也不知道能不能行,你自己试下吧 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation Const ScreenWidth: LongInt = 800; ScreenHeight: LongInt = 600;{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject); var OldFormWidth: Integer; begin Scaled := True; if Screen.Width <> ScreenWidth then begin OldFormWidth := Width; Height := LongInt(Height) * LongInt(Screen.Height) div ScreenHeight; Width := LongInt(Width) * LongInt(Screen.Width) div ScreenWidth; ScaleBy(Screen.Width,ScreenWidth); font.Size := (Width div OldFormWidth) * Font.Size; end; end;end.
程序运行时先检测分辨率 if Screen.Width = 1024 then begin //设置窗体最大化 Self.WindowState := wsMaximized; end else begin //大小自己定 Self.Width := 800; Self.Height := 600; end;
const ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.} ScreenHeight: LongInt = 600; Orignwidth=800; Orignheight=600; if (screen.width<>orignwidth) then begin height:=longint(height)*longint (screen.height) div orignheight; width:=longint(width)*longint (screen.width) div orignwidth; scaleby(screen.width , orignwidth);
都设置好了Align,窗体大小变动对组件显示是不会有影响的。自己研究一下吧
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
Const
ScreenWidth: LongInt = 800;
ScreenHeight: LongInt = 600;{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var OldFormWidth: Integer;
begin
Scaled := True;
if Screen.Width <> ScreenWidth then
begin
OldFormWidth := Width;
Height := LongInt(Height) * LongInt(Screen.Height) div ScreenHeight;
Width := LongInt(Width) * LongInt(Screen.Width) div ScreenWidth;
ScaleBy(Screen.Width,ScreenWidth);
font.Size := (Width div OldFormWidth) * Font.Size;
end;
end;end.
if Screen.Width = 1024 then
begin
//设置窗体最大化
Self.WindowState := wsMaximized;
end
else
begin
//大小自己定
Self.Width := 800;
Self.Height := 600;
end;
ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.}
ScreenHeight: LongInt = 600;
Orignwidth=800;
Orignheight=600;
if (screen.width<>orignwidth) then
begin
height:=longint(height)*longint
(screen.height) div orignheight;
width:=longint(width)*longint
(screen.width) div orignwidth;
scaleby(screen.width , orignwidth);