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). 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'.
Snippet 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
DLLHandle := LoadLibrary('Library/Demo.Frame.dll');
If开发者_JS百科 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. You could try to convert your Delphi frame into a COM control and use this from within your application.
精彩评论