Embedding a form within a C# form.

I need to open an MDI child form in a C# MDI application.

The problem is that this MDI child form is loaded via reflection from a Delphi.NET assembly. Despite my best efforts, this just does not work. At All. Period. Regular delphi.net forms are fine, MDI children are most certainly not.

But I really, really, really need this to work.

So, I'm, trying to find a different approach.

Is there any way to embed a form in another form? For example, in delphi, there is  a component called a FormPanel. This allows a form to be placed within in it, acting as its container. Is there something similar in C# (or any other .NET language)?

Thanks for any help at all.

Steve




steve-westAsked:
Who is Participating?
 
Mihai StancescuConnect With a Mentor Software Engineer Commented:
You can try using the Com SetParent Function(). Example:
//First import the function from COM+
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

//then add it to our form

Form FrmChild = new Form();
FrmChild.Text = "Test form";
SetParent(FrmChild.Handle, this.Handle);
FrmChild.Show();

Hope this helps!

Regads,
Mishu
0
 
steve-westAuthor Commented:
Mishu007:

Thanks for this - on the face of it it's just what I'm after. However, it doesn't seem to work for C# Mdi Child forms.

if I load a form from delphi and reparent it within a standard c#  FormX, it appears within FormX

If FormX then has MDIParent = this, the reparented form doesn't seem to appear.

Steve
0
 
steve-westAuthor Commented:
Actually forget what I've just said - it does work, well done.

Thanks a lot.

Steve
0
 
Mihai StancescuSoftware Engineer Commented:
You're welcome.

Mishu
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.