簡體   English   中英

在C#中加載Win32控件(特別是WPF)

[英]Loading a Win32 control in C# (specifically WPF)

我已經編寫了一組封裝了Delphi Frame的Win32 dll(請參見下面的代碼段1),並且可以通過加載dll並分配正確的變量將它們加載到另一個Delphi程序中(代碼段2)。 我現在希望能夠在C#中做同樣的事情(我可以​​用pinvoke加載DLL,但是不確定如何將控件連接到基本WPF“表單”。

片段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;

任何幫助將不勝感激。

我不確定是否可以做到這一點-特別是在使用WPF時。 您可以嘗試將Delphi框架轉換為COM控件,然后在應用程序中使用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM