2009年8月8日土曜日

SetFormAutoSize

with oForm do RMT 携帯
i_nw := screen.Width; RMT 携帯
i_nh := screen.Height; AION 紹介
r_wbl := i_nw/800;
r_hbl := i_nh/600;
width := trunc(Width*r_wbl);
Height := trunc(Height*r_wbl);

if i_nw = 800 then
Exit;

case i_nw of
800 : i_nchgsize := 0;
640 : i_nchgsize := -1;
1024 : i_nchgsize := 1;
end;

if i_nw >1024 then
i_nchgsize := 2;

for i_i:=0 to ComponentCount -1 do
begin
if ( (Components[i_i] is TControl) and (not (Components[i_i] is TToolButton)) ) then
with TControl(Components[i_i]) do
begin
Width := trunc(Width* r_wbl);
Height := trunc(Height* r_hbl);
top := trunc(top* r_hbl);
left := trunc(left* r_wbl);
end;

if (Components[i_i] is TLabel)
or (Components[i_i] is TPanel)
or (Components[i_i] is TEdit)
or (Components[i_i] is TDBEdit)
or (Components[i_i] is TCustomGrid)
or (Components[i_i] is TBitBtn)
or (Components[i_i] is TButton)
or (Components[i_i] is TSpeedButton) then

with TLabel(Components[i_i]) do
begin
if not ((i_nchgsize <0) and (Font.Size <=10) and
not (fsBold in Font.Style)) then
Font.Size := Font.Size + i_nchgsize;
end;

if ( (Components[i_i] is TCustomGrid) or (Components[i_i] is TDBGrid) ) then
with TDBGrid(Components[i_i]) do
begin
for i_j:=0 to Columns.Count -1 do
begin
Columns[i_j].Width := trunc(Columns[i_j].Width * r_wbl);
Columns[i_j].Font.Size := Columns[i_j].Font.Size+ i_nchgsize;
Columns[i_j].Title.Font.Size := Columns[i_j].Title.Font.Size+ i_nchgsize;
end;
end;
end;

oForm.SetBounds((Screen.Width -Width) div 2,
(Screen.Height - Height) div 2,
Width, Height);
Font.Size := Font.Size + i_nchgsize;
end;

0 件のコメント:

コメントを投稿