1
votes

We would like to open some Delphi (win32) forms from .NET and embed the Delphi Form in a .NET MDI-form. If we just call the exported method in our Delphi DLL it is no problem to embed the form, however then we have problems with shortcuts and keyboard events in general. We believe that it’s because of incompatible messageloops. We’ve then tried to execute an Application.Run in the exported procedures in our Delphi DLL’s on a separate .NET-thread and it works the first time, but fails when we try to open the form more than once. Does anyone know how to interop the way we would like to do it: embed a win32 Delphi Form in a .NET Winform?

@All: First of all, thanks for your responses We found a solution to our problem: We moved the Delphi Application.Run into the exported procedure that starts the windows.

2
Exposing your form as an activex could do the jobDavid Heffernan
The ActiveX approach means that your Delphi app is a control inside a .Net form, and the .Net form will do the form-level hotkey window message processing, and that ought to work much nicer than a Delphi window reparented to .net window.Warren P

2 Answers

2
votes

If you have the source, you could try porting it to Delphi Prism, which generates .NET code. Although, if you're using the VCL, you're fighting an uphill battle. Whereas Delphi 2006 had a .NET implementation of the VCL, Prism is just Object Pascal for .NET with no VCL adapter.

Another tool that is available is Hydra I haven't used it personally, but they claim to provide interop between .NET and "legacy" Delphi. If it works as they claim it does, it might be your best bet for transitioning your old Delphi code to a .NET application.

0
votes

I would probably run the Delphi application in a separate process, set the parent window for the Delphi windows to your MDI container (instead of the default: the desktop, referenced by HWND 0), and marshal any necessary data between processes using typical inter-process messaging.

Then again, this is essentially the same as exposing your form as an ActiveX object. I just like to take Google Chrome's approach and isolate windows/tabs into separate processes.