使软件的界面适应与不同的显示器与
软件适应不同的显示分辨率的实质是
一样的,因此:
你必须控制软件界面中构件的尺寸和Screen.Width以及Screen.Height的 比例,
而Screen.Width以及Screen.Height就是显示分辨率的具体值的大小。
软件适应不同的显示分辨率的实质是
一样的,因此:
你必须控制软件界面中构件的尺寸和Screen.Width以及Screen.Height的 比例,
而Screen.Width以及Screen.Height就是显示分辨率的具体值的大小。
然后就调整你的程序的大小吧
Form.font.charset:=GB2312_CHARSET;
在任何显卡,任何分辨率下窗体都不会变形的。
WIDTHSTD=640;
HEIGHTSTD=480;procedure TForm1.FormCreate(Sender: TObject);
var
// Hor,Vert:Integer;
i:Integer;
begin
// Hor:=GetDeviceCaps(GetDC(0),HORZRES);
// Vert:=GetDeviceCaps(GetDC(0),VERTRES);
// Edit1.Text:=IntToStr(Hor);
// Edit2.Text:=IntToStr(Vert);
// Form1.Width:=Form1.Width*round((Hor/HortOld));
// Form1.Height:=Form1.Height*round((Vert/VertOld));
// Edit3.Text:=IntToStr(Form1.Width);
// Edit4.Text:=IntToStr(Form1.Height);
//////////////////////////////////////////////
hRatio := Screen.Height/HEIGHTSTD;
wRatio := Screen.Width/WIDTHSTD;////////////////////////////////////////////
Self.Left := round(Self.Left*wRatio);
Self.Top := round(Self.Top * hRatio);
Self.Width := round(Self.Width*wRatio);
Self.Height := round(Self.Height*hRatio);
////////////////////////////////////////////
for i:=0 to Self.ComponentCount-1 do
begin
if Self.Components[i] is TWinControl then
begin
TWinControl(Self.Components[i]).Left :=round(TWinControl(Self.Components[i]).Left * wRatio);
TWinControl(Self.Components[i]).top :=round(TWinControl(Self.Components[i]).top * hRatio);
TWinControl(Self.Components[i]).Width :=round(TWinControl(Self.Components[i]).width * wRatio);
TWinControl(Self.Components[i]).Height :=round(TWinControl(Self.Components[i]).height * hRatio);
end;
end;
end;你如果要动态的话,就要在Form1.resize中加入上面的东东了
WIDTHSTD=640;
HEIGHTSTD=480;procedure TForm1.FormCreate(Sender: TObject);
var
// Hor,Vert:Integer;
i:Integer;
begin
// Hor:=GetDeviceCaps(GetDC(0),HORZRES);
// Vert:=GetDeviceCaps(GetDC(0),VERTRES);
// Edit1.Text:=IntToStr(Hor);
// Edit2.Text:=IntToStr(Vert);
// Form1.Width:=Form1.Width*round((Hor/HortOld));
// Form1.Height:=Form1.Height*round((Vert/VertOld));
// Edit3.Text:=IntToStr(Form1.Width);
// Edit4.Text:=IntToStr(Form1.Height);
//////////////////////////////////////////////
hRatio := Screen.Height/HEIGHTSTD;
wRatio := Screen.Width/WIDTHSTD;////////////////////////////////////////////
Self.Left := round(Self.Left*wRatio);
Self.Top := round(Self.Top * hRatio);
Self.Width := round(Self.Width*wRatio);
Self.Height := round(Self.Height*hRatio);
////////////////////////////////////////////
for i:=0 to Self.ComponentCount-1 do
begin
if Self.Components[i] is TWinControl then
begin
TWinControl(Self.Components[i]).Left :=round(TWinControl(Self.Components[i]).Left * wRatio);
TWinControl(Self.Components[i]).top :=round(TWinControl(Self.Components[i]).top * hRatio);
TWinControl(Self.Components[i]).Width :=round(TWinControl(Self.Components[i]).width * wRatio);
TWinControl(Self.Components[i]).Height :=round(TWinControl(Self.Components[i]).height * hRatio);
end;
end;
end;你如果要动态的话,捕捉消息了
你的程序我运行了,提示没有定义hRatio,wRatio;
我将hRatio,wRatio定义成Real或者extended型,都不行,界面好象变得更乱.请都都指教!