怎样使delphi里的控件随窗体的大小变化而变化
发布网友
发布时间:2022-04-22 17:55
我来回答
共1个回答
热心网友
时间:2023-05-19 11:40
给楼主一段代码,可以自动计算窗口大小的变化量,希望会有用吧。
procere TFStateReopen.FormCreate(Sender: TObject);
begin
InitClientHeight:= ClientHeight; //要先在窗体类中声名这些Integer变量
InitClientWidth:= ClientWidth;
CurClientHeight:= ClientHeight;
CurClientWidth:= ClientWidth;
end;
procere 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;