Loading a Win32 control in C# (specifically WPF)

Posted by Mmarquee on Stack Overflow See other posts from Stack Overflow or by Mmarquee
Published on 2010-06-15T09:31:05Z Indexed on 2010/06/15 10:22 UTC
Read the original article Hit count: 208

Filed under:
|
|
|

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 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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about delphi