[英]Loading a Win32 control in C# (specifically WPF)
I have written a set of Win32 dlls that encapsulate a Delphi Frame (see Snippet 1 below), and can load them into another Delphi program by loading the dll and assigning the right variables (Snippet 2). 我已经编写了一组封装了Delphi Frame的Win32 dll(请参见下面的代码段1),并且可以通过加载dll并分配正确的变量将它们加载到另一个Delphi程序中(代码段2)。 I now want to be able to do the same thing in C# (I can load the DLL in pinvoke, but am unsure how to connect up the control to the basic WPF 'form'.
我现在希望能够在C#中做同样的事情(我可以用pinvoke加载DLL,但是不确定如何将控件连接到基本WPF“表单”。
Snippet 1 片段1
var
frame : TFrame1;
function CreateFrame(hParent:TWinControl):Integer; stdcall; export;
begin
try
frame := TFrame1.Create(hParent);
frame.Parent := hParent;
frame.Align := alClient;
finally
result := 1;
end;
end;
exports CreateFrame name 'CreateFrame';
Snippet 2 片段2
DLLHandle := LoadLibrary('Library/Demo.Frame.dll');
If DLLHandle > 32 then
begin
ReturnValue := GetProcAddress(DLLHandle, 'CreateFrame');
end;
ts1 := TTabSheet.Create(PageControl1);
with ts1 do
begin
PageControl := PageControl1;
Name := 'tsExternal';
Caption := 'External';
Align := alClient;
ReturnValue (ts1);
end;
Any help would be greatly appreciated. 任何帮助将不胜感激。
I'm not sure whether this can be done - especially when using WPF. 我不确定是否可以做到这一点-特别是在使用WPF时。 You could try to convert your Delphi frame into a COM control and use this from within your application.
您可以尝试将Delphi框架转换为COM控件,然后在应用程序中使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.