我已经编写了一组Win32 dll,它们封装了一个Delphi框架(参见下面的代码段1),并且可以通过加载dll并分配正确的变量(代码段2)将它们加载到另一个Delphi程序中。我现在想在C#中做同样的事情(我可以在pinvoke中加载DLL,但是不确定如何将控件连接到基本的WPF‘form’。
代码段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';
代码段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;
任何帮助都将不胜感激。