Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form inside form-MDI help?

Status
Not open for further replies.

pierrotsc

Programmer
Nov 25, 2007
358
US
Ok, I'm trying to put a form inside a form. I have my main form (Tmain) as a fsMDIform.
Now I have another form changed from fsnormal to fsMDIChild (Tsecond).
When I click a button on Tmain, i would like Tsecond to open inside. Is that possible?
I have been trying for hours without success.
Thanks.
PO
 
First off we would need to check if the MDI Child is on the Auto Create list.
That would be found under Project -> Options depending on your version of Delphi.
You can also tell by looking at the Project source.

If it is not, you will need to create the Child Form.

Code:
uses uchild;
...
procedure TfrMain.CreateChildForm
         (const childName : string);
  var Child: TfrChild;
begin
  Child := TfrChild.Create(Application);
  Child.Caption := childName;
end;

When going to get rid of the child form, you could use the Child.Free; If you want the child form to free its memory when they close it, rather than just be minimized, add the line "Action := caFree;" to the Child's OnClose event handler.

A great helper can be found here at Delphi.about.com

Let me know if this helps. I suppose my part of the post won't help much if the Child Is in fact on the auto-create list. But, you could always take it off the list to save on memory usage when possible.

~
Chuck Norris is the reason Waldo is hiding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top