假设你在800*600的分辨率下设计的form,第一步: inplementation const ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.} ScreenHeight: LongInt = 600;{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject); begin scaled := true; if (screen.width <> ScreenWidth) then begin height := longint(height) * longint(screen.height) div ScreenHeight; width := longint(width) * longint(screen.width) div ScreenWidth; scaleBy(screen.width, ScreenWidth); end; end;下一步,要让每个子控制的字体改变到合适的大小: //下面的不知放在那里? type TFooClass = class(TControl); { needed to get at protected } { font property }var i: integer; begin for i := ControlCount - 1 downto 0 do TFooClass(Controls[i]).Font.Size := (NewFormWidth div OldFormWidth) * TFooClass(Controls[i]).Font.Size; end;
var
sx, sy: Integer;
DevMode: TDeviceMode;
begin
sx := GetSystemMetrics(SM_CXSCREEN); //分辨率宽
sy := GetSystemMetrics(SM_CYSCREEN); //分辨率高
//用于在程序结束时把分辨率 改回原始状态
screenx := sx; //分辨率宽
screeny := sy; //分辨率高
if (sx <> 800) and (sy <> 600) then
begin
DevMode.dmFields := DM_PELSWIDTH or DM_PELSHEIGHT;
DevMode.dmPelsWidth := 800;
DevMode.dmPelsHeight := 600;
ChangeDisplaySettings(DevMode,0); //设置新的显示参数
end;
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
sx, sy: Integer;
DevMode: TDeviceMode;
begin
sx := GetSystemMetrics(SM_CXSCREEN); //分辨率宽
sy := GetSystemMetrics(SM_CYSCREEN); //分辨率高
if (sx <> screenx) and (sy <> screeny) then
begin
DevMode.dmFields := DM_PELSWIDTH or DM_PELSHEIGHT;
DevMode.dmPelsWidth := screenx;
DevMode.dmPelsHeight := screeny;
ChangeDisplaySettings(DevMode,0); //设置新的显示参数
end;
actiON:=cafree;
end;
如果改动系统分辨率这可不行
我的设计是在1024*768下做的(17的显示器)
但是把客户改到1024*768 字体太小,用户瞧不清!!
siyu2002(bayer) 的方法不知可否能实现!
inplementation
const
ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.}
ScreenHeight: LongInt = 600;{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
scaled := true;
if (screen.width <> ScreenWidth) then
begin
height := longint(height) * longint(screen.height) div ScreenHeight;
width := longint(width) * longint(screen.width) div ScreenWidth;
scaleBy(screen.width, ScreenWidth);
end;
end;下一步,要让每个子控制的字体改变到合适的大小:
//下面的不知放在那里?
type
TFooClass = class(TControl); { needed to get at protected }
{ font property }var
i: integer;
begin
for i := ControlCount - 1 downto 0 do
TFooClass(Controls[i]).Font.Size :=
(NewFormWidth div OldFormWidth) *
TFooClass(Controls[i]).Font.Size;
end;