D
ddzhouqian
Unregistered / Unconfirmed
GUEST, unregistred user!
如题:我在form1上动态创建了多个panel后,如何在对form1大小的改变(resize事件中),实时的改变panel的大小(动态创建的),创建的panel比较多,如何防止form1处于假死状态,并能够快速刷新。部分代码:
procedure TMainForm.FormResize(Sender: TObject);
var i,j:Integer;
v_count:Integer;
s_count:Integer;
begin
v_count:=FCount.x;
s_count:=FCount.y;
for i:=Low(FPanelList) to High(FPanelList)do
begin
for j:=Low(FPanelList) to High(FPanelList)do
begin
if FPanelList[i,j]<>nil then
begin
FPanelList[i,j].Width:=(panel4.Width) div v_count;
FPanelList[i,j].DefaultWith:=FPanelList[i,j].Width;
FPanelList[i,j].Height:=(panel4.Height) div s_count;
FPanelList[i,j].DefaultHeight:=FPanelList[i,j].Height;
FPanelList[i,j].Left:=panel4.Left+i*(FPanelList[i,j].Width);
FPanelList[i,j].DefaultLeft:=FPanelList[i,j].Left;
FPanelList[i,j].Top:=panel4.Top+j*(FPanelList[i,j].Height);
FPanelList[i,j].DefaultTop:=FPanelList[i,j].Top;
//
FPanelList[i,j].ChangeTopAndBottom_PanelSize();
end;
end;
end;
end;
procedure TMainForm.FormResize(Sender: TObject);
var i,j:Integer;
v_count:Integer;
s_count:Integer;
begin
v_count:=FCount.x;
s_count:=FCount.y;
for i:=Low(FPanelList) to High(FPanelList)do
begin
for j:=Low(FPanelList) to High(FPanelList)do
begin
if FPanelList[i,j]<>nil then
begin
FPanelList[i,j].Width:=(panel4.Width) div v_count;
FPanelList[i,j].DefaultWith:=FPanelList[i,j].Width;
FPanelList[i,j].Height:=(panel4.Height) div s_count;
FPanelList[i,j].DefaultHeight:=FPanelList[i,j].Height;
FPanelList[i,j].Left:=panel4.Left+i*(FPanelList[i,j].Width);
FPanelList[i,j].DefaultLeft:=FPanelList[i,j].Left;
FPanelList[i,j].Top:=panel4.Top+j*(FPanelList[i,j].Height);
FPanelList[i,j].DefaultTop:=FPanelList[i,j].Top;
//
FPanelList[i,j].ChangeTopAndBottom_PanelSize();
end;
end;
end;
end;