dll内有一TFrame1
外部接口函数
function x(app:tapplication):Tframe;stdcall;
begin
  Result:=tframe1.create(app);
end;主调程序
主窗体上有一个panel1
我这么调没报错,但也没显示任何内容的问题
var
f:tframe;
begin
  f:=x(application);
  f.parent:=panel1;
  f.show;
end;

解决方案 »

  1.   

    DLL模块
    ...
    uses
      SysUtils,
      Forms,
      Windows,
      Messages,
      Classes,
      DLLFormUnit in 'DLLFormUnit.pas' {frmDLLForm};{$R *.res}function CreateDLLForm(App: TApplication):TForm;
    begin
      Application := App;
      Application.CreateForm(TfrmDLLForm, frmDLLForm);
      result:=frmDLLForm;
    end;exports
      CreateDLLForm;
    begin
    end.调用DLL的主窗口
    ...
    type
      LoadDLLFrm=function(App:TApplication):TForm;
    ...
    var
      
      DLLForm:TForm; //定义一个全局变量
    implementation
    procedure TForm1.Button1Click(Sender: TObject);
    var
      DLLHandle: THandle;
      DLLSub: LoadDLLFrm;
    begin
      DLLHandle := LoadLibrary('d:\prjDLL.dll');
      if DLLHandle <> 0 then
      begin
        @DLLSub := GetProcAddress(DLLHandle, 'CreateDLLForm');
        if Assigned(DLLSub) then
        begin
          DLLForm := DLLSub(Application);
        end;
        DLLForm.Parent:=Panel1;
        DLLForm.Align:=alClient;
        DLLForm.Show;
      end;
    end;
      

  2.   

    二楼的老大,看清楚点好不好,我是说frame不是说form,调form小弟我早会啦,有哪位大虾知道啊,麻烦告诉一声