On creation of a Form, I am setting MyPanel to not be visible:
<code>constructor MyForm.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
TopPanel.Align := alTop; // parented to MainPanel
MyPanel.Align := alTop; // parented to MainPanel
MainPanel.AutoSize := True;
AutoSize := True;
if foo then
begin
MyPanel.Visible := False;
// force client height to adjust and catch the not visible panel
Visible := True;
Visible := False;
end;
end;
</code>
<code>constructor MyForm.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
TopPanel.Align := alTop; // parented to MainPanel
MyPanel.Align := alTop; // parented to MainPanel
MainPanel.AutoSize := True;
AutoSize := True;
if foo then
begin
MyPanel.Visible := False;
// force client height to adjust and catch the not visible panel
Visible := True;
Visible := False;
end;
end;
</code>
constructor MyForm.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
TopPanel.Align := alTop; // parented to MainPanel
MyPanel.Align := alTop; // parented to MainPanel
MainPanel.AutoSize := True;
AutoSize := True;
if foo then
begin
MyPanel.Visible := False;
// force client height to adjust and catch the not visible panel
Visible := True;
Visible := False;
end;
end;
Without the Visible toggling, the Form’s ClientHeight/Height acts as though MyPanel is still visible, including MyPanel’s Height. Once I show the Form or toggle the Visible property, the ClientHeight will adjust to not include MyPanel’s height. I would like to know if there is a better way to get the height to update without toggling the Visible property, as I am storing the ClientHeight on creation and it is not accurate by the time the form is shown.