I have a .NET 4 WinForm application that displays forms from a Delphi 7 .dll. I had some questions yesterday about how to get the Delphi form to behave correctly when shown modally. That was answered here.
I export a method from the Delphi .dll that creates an instance of the Delphi form, returning a pointer to that form to .NET. I also export a method to show the Delphi form. The Show method two parameters: owner of type integer; and form of type Pointer.
I call the CreateForm method, which creates the Delphi form, passing Delphi's Application object to the form's constructor. I store the returned pointer in .NET. I then call the Show method, passing the handle from the .NET application's main form and the pointer for the Delphi form.
I then assign that handle to Delphi's Application.Handle
property.
This solved my original issue.
Now I have some other issues:
The Delphi form shows a button on the Windows taskbar. The only way that I have found so far to suppress the taskbar button is to create the Delphi form as a tool window (either through setting the forms's
BorderStyle := bsToolWindow
or assigningWS_EX_TOOLWINDOW
to the form's style). I need the Delphi form to be a normal style form, but I don't want the toolbar button to show, similar to how child forms behave in a native Delphi or .NET app. And by native I mean where the entire application is written in the given language.The Delphi form does not minimize when the .NET application is minimized. I need the Delphi form(s) to minimize when the .NET application's main form is minimized, similar to how child forms behave in a native Delphi or .NET app.
I'm not sure, but this does feel like an ownership issue. It seems that Delphi forms don't "know" that they are part of the .NET application.
So my basic question is: How do I get the Delphi forms to behave as though they were native forms of the application?
Further considerations: I am developing on Windows 7, but the application needs to behave the same on XP and Vista, as well.