I have an application that has 5 different sized frames. I’d like to dynamically re-size the main form to fit the frame when I move from one frame to another.
I can use the MinHeight/MinWidth properties of the frame to force the main form to fit the frame, but then when moving to a smaller frame, the main form does not adjust it’s size.
Any ideas?
–Edit
...
TFormMain = Class(TForm)
...
public
FrameImportPackage: TFrameImportPackage;
...
procedure TFormMain.MenuPackagesImportClick(Sender: TObject);
begin
if not (Assigned(FrameImportPackage)) then
begin
FrameImportPackage := TFrameImportPackage.Create(Self);
FrameImportPackage.LabelFrameCaption.Caption := 'Import or Edit a Package';
end
else
begin
FrameImportPackage.BringToFront;
end;
FrameImportPackage.Parent := Self;
end;
–Edit
Regards, Pieter
If I understand your question correctly, you’ve got frames that don’t change size, you want the form to update size to fit your frames. Let Delphi handle that for you, using the
AutoSizeproperty.Set
AutoSize = Truefor your form.I’ve tested
AutoSizewith the following code, usingDelphi 2010:Panel1). Make sure the panel is not too small, because we’ll write code to decrease it’s size at runtime.AutoSizeproperty toTrue.Button1andButton2.Code:
This essentially gives you two ways of decreasing the size of the panel, to handle two possible scenarios:
Button1frees the old panel and creates a new, smaller panel.Button2directly resize the existing panel. Both work as expected!