0

こんにちは、メイン フォームからプラグイン dll を作成し、dll を呼び出します

type
  TCreateCustomWindow=function(ParentFrame:TWinControl; ParentHandle:integer; ParentRect:TRect; var WinHandle:THandle):integer; stdcall;

var
CreateW:TCreateCustomWindow;
begin
CreateW:=GetProcAddress(FHLib,'Create_LEF');
if Assigned(CreateW) then
begin
  if Assigned(CreateW) then LEFT_OKNO:=CreateW(ScrollBox2, ScrollBox2.Handle, ClientRect, FChildHandle);
end;

dll自体では、次のようになります

function Create_LEF(ParentFrame:TWinControl; ParentHandle:integer; ParentRect:TRect; var WinHandle:THandle):integer; stdcall; export;
begin
  Result:=0;
  WinHandle:=0;
  try
    FD3:=TForm3.Create(nil);
    FD3.Parent:= ParentFrame;
    Result:=integer(FD3);
    WinHandle:=FD3.Handle;
    if ParentHandle<>0 then begin
      SetParent(WinHandle,ParentHandle);
      with FD3 do begin
      FD3.Align:=alTop;
      FD3.Width:=ParentFrame.Width;
      hirina_left:=ParentFrame.Width;
      FD3.Show;
      end;
    end;
  except
    On E:exception do MessageDlg(E.Message,mtError,[mbOK],0);
  end;
end;

問題は、セル cxGrid を編集できないことです。

4

1 に答える 1

0

私は以前にこれに遭遇しましたが、それを回避する方法がいくつかあります。ずいぶん前のことなので、少し試行錯誤する必要があります。

function Create_LEF(ParentFrame:TWinControl; ParentHandle:integer; ParentRect:TRect; var WinHandle:THandle):integer; stdcall; export;
begin
  Result:=0;
  WinHandle:=0;
  try
    FD3:=TForm3.Create(nil);
    FD3.Parent:= ParentFrame;
    Result:=integer(FD3);
    WinHandle:=FD3.Handle;
    if ParentHandle<>0 then begin
      with FD3 do begin
        ParentWindow := ParentFrame.Handle;
        Parent := ParentFrame;
        Align:=alTop;
        Width:=ParentFrame.Width;
        hirina_left:=ParentFrame.Width;
        Show;
      end;
    end;
  except
    On E:exception do MessageDlg(E.Message,mtError,[mbOK],0);
  end;
end;

これで問題が解決するはずです。それができない場合は、DLL の Application.Handle をアプリケーションの Application.Handle に設定してみてください。私は通常、DLL の Init 関数でこれを行います。この関数は、DLL の Application.Handle をグローバル変数に格納し、パラメーターとして関数に渡されたアプリケーションのハンドルに再割り当てします。DLL をアンロードするときは、DLL の application.handle を元の値に戻します。そうしないと、すべてがうまくいきません。

var
    FOldHandle: THandle;

procedure Init(AHandle: THandle); stdcall;
begin
    FOldHandle := Application.Handle;
    Application.Handle := AHandle;
end;

procedure UnInit; stdcall;
begin
    Application.Handle := FOldHandle;
end;
...
于 2012-03-06T16:24:01.927 に答える