[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Opening a Delphi.NET MDI Child Form  in a C# application

Posted on 2007-10-08
5
Medium Priority
?
887 Views
Last Modified: 2013-11-23
This could be a difficult one, so please bear with me.

I've an assembly containing Delphi 2006.NET forms.

A C# app, via reflection opens these forms . This works fine - I've a C# app, opening Delphi 2006.NET forms.

Some of these forms are MDI Child forms. Exceptions are thrown - "Cannot create form - No MDI Forms are currently active" when the C# app tries to open one of these.

The C# app does have the property MDI Container = True. I realise it is the Form that I'm trying to create throwing the exception, rather than the C# application - the Delphi Form expects the opening form to be of form style fsMDIForm.

Does anyone know of a way around this? i.e. I want the MDI children (delphi forms) to be happy about opening in a C# application whose main form is an MDI Container.

I really, really, really, really need to be able to do this. Hope some genius is out there....

Thanks

Steve
0
Comment
Question by:steve-west
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:developmentguru
ID: 20035649
 Are you using these forms from another application (Delphi based) as well?  If they are used by one application you can simple make them non MDI.  For now I will assume that it is not that easy...

  You could create a TStream class to read in the MDI forms.  The primary reason for creating this class would be to ignore any attempts to set the MDI related properties.  You would likely need to look at the Delphi source and watch how it is done there.  

I honestly do not have the time to make an example right now.

Let me know if you need more.
0
 

Author Comment

by:steve-west
ID: 20039236
Yes, the forms are used from another application - a Delphi Win32 app.

Due to customer demand, we're - I'm - developing a .NET version of our application suite. The main form has to be written in C# since we're lacking a Delphi.NET version of one of the main interface components, but a C# equivalent is available.

Each application loads its screens from external packages. The Delphi Win32 ad the C# app share screens (around 3000), all of which are written in Delphi 2006, but compiled into Win32/.NET libraries.

This works fine but for the aforementioned MDI children.

You mention streams to read in the MDI forms. Whilst I have extensive  experience of delphi, you've completely lost me as to how this applies to loading a form via .NET reflection. Admittedly, I'm still learning C# and the .NET framework, but  I don't understand what you're suggesting, let alone how to implement it.


Regards

Steve
0
 

Author Comment

by:steve-west
ID: 20039488
Right then.

I'm fairly sure that it's not possible to host a MDI child form in a foreign application.

So, thinking about this from another direction, is it possible to "embed" the form in a C# window, using a panel or something similar?

For example - the C# app needs to create a delphi.net form. I'm thinking along the lines of creating a regular c# mdi child, and then embedding the form within the C# form (obviously adjusting the delphi forms formstyle to be non mdi).

Would this work and if so how?
0
 
LVL 21

Accepted Solution

by:
developmentguru earned 2000 total points
ID: 20040675
 As far as I understand it, and I must admit that I have not tried to do what you are attempting, the Reflection code is what is handling creating your form.  Delphi forms are created by reading in an XML like stream of information that defines the form.  If you could override the code doing the reflection, that may be where you would be able to turn off (ignore) the setting of MDI child properties.  

  As to the idea of being able to embed the child form in a C# window, it should work as long as you can make it an MDI parent window.  That should be a simple property setting on the window that you want to use.  Generally this would be a form though.

Let me know if any of this helps.
0
 

Author Comment

by:steve-west
ID: 20040774
I've worked through an example which will allow me to do what I want.

For MDI Child delphi forms, I create a C# MDI Child and reparent the delphi form once it's been loaded from the assembly. The delphi form has its caption hidden, client area maximized and borders turned off so that it fills the client area of the C# sharp form. I  still need to implement a certain amount of interaction between the delphi form and its host (for example, caption changing, form closing etc), but it **should** work as I want.

Thanks for all suggestions.

Steve

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 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