delphi中怎么使控件随窗口的放大和缩小动态改变自己的大小
1个回答
展开全部
给楼主一段代码,可以自动计算窗口大小的变化量,希望会有用吧。
procedure TFStateReopen.FormCreate(Sender: TObject);
begin
InitClientHeight:= ClientHeight; //要先在窗体类中声名这些Integer变量
InitClientWidth:= ClientWidth;
CurClientHeight:= ClientHeight;
CurClientWidth:= ClientWidth;
end;
procedure TFStateReopen.FormResize(Sender: TObject);
begin
inherited;
//计算可视组件的坐标变化
HeightInc:= ClientHeight - CurClientHeight;
if HeightInc > 0 then
begin
CurClientHeight:= ClientHeight;
end;
if (HeightInc < 0) and (ClientHeight > InitClientHeight) then
begin
CurClientHeight:= ClientHeight;
end;
if (HeightInc <0) and (ClientHeight <= InitClientHeight) then
begin
HeightInc:= InitClientHeight - CurClientHeight;
CurClientHeight:= InitClientHeight;
end;
WidthInc:= ClientWidth - CurClientWidth;
if WidthInc > 0 then
begin
CurClientWidth:= ClientWidth;
end;
procedure TFStateReopen.FormCreate(Sender: TObject);
begin
InitClientHeight:= ClientHeight; //要先在窗体类中声名这些Integer变量
InitClientWidth:= ClientWidth;
CurClientHeight:= ClientHeight;
CurClientWidth:= ClientWidth;
end;
procedure TFStateReopen.FormResize(Sender: TObject);
begin
inherited;
//计算可视组件的坐标变化
HeightInc:= ClientHeight - CurClientHeight;
if HeightInc > 0 then
begin
CurClientHeight:= ClientHeight;
end;
if (HeightInc < 0) and (ClientHeight > InitClientHeight) then
begin
CurClientHeight:= ClientHeight;
end;
if (HeightInc <0) and (ClientHeight <= InitClientHeight) then
begin
HeightInc:= InitClientHeight - CurClientHeight;
CurClientHeight:= InitClientHeight;
end;
WidthInc:= ClientWidth - CurClientWidth;
if WidthInc > 0 then
begin
CurClientWidth:= ClientWidth;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询