?
Solved

Embedding a form within a C# form.

Posted on 2007-10-09
4
Medium Priority
?
2,318 Views
Last Modified: 2013-11-23
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




0
Comment
Question by:steve-west
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Mihai Stancescu earned 2000 total points
ID: 20039543
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
 

Author Comment

by:steve-west
ID: 20039894
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
 

Author Comment

by:steve-west
ID: 20039934
Actually forget what I've just said - it does work, well done.

Thanks a lot.

Steve
0
 
LVL 11

Expert Comment

by:Mihai Stancescu
ID: 20040242
You're welcome.

Mishu
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question