Hi DaniWeb,

I'm new to delphi and was wondering if it is possible to embed forms inside one another.

I have several forms working by it self and I want to move them forms onto a new blank form.

Rather then copying and pasting the code is there a way I can embed these forms into my blank form? so say on the left hand side I have form 1 and right hand side form 2 but are inside the blank form.

hope that makes sense.

Thanks in Advance!

It is possible but very prone to error. This code shows how you can switch out a form in a panel in a button click event:

procedure TMainStockForm.StockTakeBtnClick(Sender: TObject);
        Panel1.Visible := true;
	    StockTakeBtn.Down := true;
	    StockTakeForm.WindowState := wsMaximized;
	    Panel1.Visible := false;

Make sure your inner form (StockTakeForm in my example) does not rely on a ModalResult.

Having said this, I think it is a much better option to put all of your "inner form" code inside a page control and switch tabs. Two inner forms in a single form at the same time probably won't work, but you could just use panels or page controls for this too.

Anyway have a play with the example and see how you go. Good luck! :)

Thank you for the reply, but I found and worked on a solution before you posted.

This is for a project where you can interact with the objects and edit them at run time. So In the end I used my canvas as a MDI Parent then create MDI Children at run time but hide the window frames so they do not look like windows and look just like the forms.

If anyone else gets stuck with this I would be happy to post my code if needed.

This article has been dead for over six months. Start a new discussion instead.