建一窗体,在窗体上加3个可视控件,在var段定义如下变量: x1,y1:integer; cl,ct,cw,ch:array [0..2] of real;//数组上限由可视控件数目而定在窗体的OnCreate事件输入如下代码: procedure TForm1.FormCreate(Sender: TObject); var i:integer; begin //取窗体的原始大小 x1:=form1.ClientWidth; y1:=form1.ClientHeight; //取各控件的原始大小和位置 for i:=0 to 2 do begin cw[i]:=form1.Controls[i].Width; cl[i]:=form1.Controls[i].Left; ch[i]:=form1.Controls[i].Height; ct[i]:=form1.Controls[i].Top; end; end;在窗体的OnResize事件输入如下代码: procedure TForm1.FormResize(Sender: TObject); var x,y,i:integer; begin x:=form1.ClientWidth; y:=form1.ClientHeight; for i:=0 to 2 do begin cl[i]:=cl[i]*x/x1; ct[i]:=ct[i]*y/y1; form1.Controls[i].Left:=round(cl[i]); form1.Controls[i].Top:=round(ct[i]); cw[i]:=cw[i]*x/x1; form1.Controls[i].Width:=round(cw[i]); ch[i]:=ch[i]*y/y1; form1.Controls[i].Height:=round(ch[i]); end; x1:=x; y1:=y; end; 以上在WIN 2000 delphi 5/7下调试通过。
复杂的变化最好还是自己写
x1,y1:integer;
cl,ct,cw,ch:array [0..2] of real;//数组上限由可视控件数目而定在窗体的OnCreate事件输入如下代码:
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
//取窗体的原始大小
x1:=form1.ClientWidth;
y1:=form1.ClientHeight;
//取各控件的原始大小和位置
for i:=0 to 2 do
begin
cw[i]:=form1.Controls[i].Width;
cl[i]:=form1.Controls[i].Left;
ch[i]:=form1.Controls[i].Height;
ct[i]:=form1.Controls[i].Top;
end;
end;在窗体的OnResize事件输入如下代码:
procedure TForm1.FormResize(Sender: TObject);
var x,y,i:integer;
begin
x:=form1.ClientWidth;
y:=form1.ClientHeight;
for i:=0 to 2 do
begin
cl[i]:=cl[i]*x/x1;
ct[i]:=ct[i]*y/y1;
form1.Controls[i].Left:=round(cl[i]);
form1.Controls[i].Top:=round(ct[i]);
cw[i]:=cw[i]*x/x1;
form1.Controls[i].Width:=round(cw[i]);
ch[i]:=ch[i]*y/y1;
form1.Controls[i].Height:=round(ch[i]);
end;
x1:=x;
y1:=y;
end;
以上在WIN 2000 delphi 5/7下调试通过。
可以保证大小会随着变化,但图象质量嘛,,,,,,,5折!