0

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)

Oussaki
  • 1,449
  • 2
  • 21
  • 30
  • 1
    Have you tried using `alClient`? That's how I do it. – Jerry Dodge Sep 12 '15 at 12:35
  • 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 Sep 12 '15 at 12:37
  • @Wosi It's perfectly normal practice. – Jerry Dodge Sep 12 '15 at 12:38
  • @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 Sep 12 '15 at 12:42
  • @Wosi it works very normal . – Oussaki Sep 12 '15 at 12:42
  • 2
    @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 Sep 12 '15 at 12:44

1 Answers1

4

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;
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490