0
votes

i'm trying to dynamically show a form in a TPanel using this function

procedure Show_form_in_panel(form: TForm; Panel: Tpanel);
begin
  form.Parent := Panel;
  form.Show;   
  form.WindowState := wsMaximized;
end; 

the form is showing very normal but he's not maximized in my panel and also i want to make this form automaticly react like components that have the Alight property = (alClient)

1
Have you tried using alClient? That's how I do it.Jerry Dodge
Showing a TForm inside a TPanel sounds unusrual to me. Is this supposed to work? Have you considered using a TFrame instead of a TForm?Wosi
@Wosi It's perfectly normal practice.Jerry Dodge
@JerryDodge Thanks. I read for the first time that someone wants to show a form in a panel. In the projects I have worked on there have always been TFrames for sharing the same piece of UI over different places. Is there any advantage of using a form in a panel?Wosi
@Wosi One big advantage of doing this is for example docking or undocking - or a form which might also be used elsewhere on its own. After all, a form is just another control, and other win controls are also just other windows. You can pop-out a panel or other controls and treat them as bordered forms also.Jerry Dodge

1 Answers

4
votes

I want to make this form automatically react like components that have the Align property set to alClient.

That's the solution. Remove

form.WindowState := wsMaximized;

and replace with

form.Align := alClient;