问题描述
我需要分配一个.NET 4 WinForm应用程序作为一个Delphi 7形式的所有者。
I need to assign a .NET 4 Winform application as the owner of a Delphi 7 form.
我已经创建了德尔福一个.dll其中包含的形式。德尔福.DLL出口的方法来创建和显示形式。
I have created a .dll in Delphi which contains the form. The Delphi .dll exports methods to create and display the form.
我已经成功加载了德尔福.dll文件在我的.net应用程序,并显示形式。
I have successfully loaded the Delphi .dll in my .NET app, and displayed the form.
现在我需要能够分配的.NET应用程序(或.net应用程序的主要形式)作为德尔福形式的所有者。
Now I need to be able to assign the .NET app (or main form of the .NET app) as the owner of the Delphi form.
我有previously创建一个Delphi应用程序,互操作性展示到.NET通过COM,并分配德尔福的应用程序为使用以下类的.NET形式的所有者:
I have previously created a Delphi app that interops to .NET through COM, and assigns the Delphi app as the owner of the .NET forms using the following class:
public class WindowHandleWrapper : IWin32Window
{
public HandleRef m_Handle;
public IntPtr Handle
{
get
{
return m_Handle.Handle;
}
}
public WindowHandleWrapper(IntPtr handle)
{
m_Handle = new HandleRef(this, handle);
}
}
在Delphi应用程序句柄传递给 WindowHandleWrapper
构造一个整数。
我怀疑,该解决方案将是类似的东西,如:传递的句柄的Delphi为整数。但是,德尔福类型的表单的所有者属性是TComponent的。我只是不完全知道如何分配.NET句柄作为德尔福形式的所有者。
I suspect that the solution will be something similar, e.g. passing a handle to Delphi as an integer. However, the Delphi type for the Owner property of a form is TComponent. I'm just not exactly sure how to assign the .NET handle as the Delphi form's owner.
任何想法?
推荐答案
通过你的WinForm的句柄DLL作为参数,并创建之前将其分配给 Application.Handle
和显示形式模态。
Pass your WinForm handle to the DLL as a parameter, and assign it to Application.Handle
before creating and showing the form modally.
这篇关于我怎么可以指定一个.NET 4的WinForm应用的德尔福7形式所有者的财产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!