在DLL中
library DllMain;
……function fm:TForm;stdcall;
begin
 fmDllMain := TfmDllMain.Create (nil);
 Result:=fmDllMain;
 {procedure TForm1.Button1Click(Sender: TObject);
VAR
AA:TForm;
begin
 AA:=zjpFm;
 AA.Parent:=nil;
 AA.ShowModal;
 FreeAndNil(AA);
end;}
end;
exports  fm      name 'zjpfm';
begin
end.
我想这样调用。function  zjpfm:TForm;stdcall;external 'Win32\Debug\DllMain.dll';……procedure TForm1.FormCreate(Sender: TObject);
var
cc:TForm;
begin
  cc:=TForm.Create(Application);
  cc:=zjpFm;
  //cc:=TForm.Create(Application);
  cc.Parent:=Self
  cc.Visible:=True;
end;
可是这样用有问题。会有异常出现,还有就是关不掉cc

解决方案 »

  1.   

    http://blog.csdn.net/zhenghui1/article/details/5940510
      

  2.   


    procedure SynAPP(App:THandle );stdcall; 
    begin end; 
     
    procedure ShowForm;stdcall; 
    begin end; 这两个是过程和我现在的情况不一样啊???????????
    我要的是返回窗体,然后类似
      Form2:=TForm2.Create(Application);/
      Form2.Visible:=False;
      Form2.Parent:=Self;
      Form2.Align:=alClient;
      Form2.BorderStyle := bsNone;//不要标韪
      Form2.Visible:=True;//显示这样的有没有??????
      

  3.   

    记得在dll函数中一定要加入application的句柄function ABC(AppHandle:HWND; Btns: LongInt): LongInt; export; stdcall;
    begin
      Application.Handle:=AppHandle;  IsGetButtonList := True;  frmChild:=TfrmABC.Create(Application);
      try
        frmChild.GetChildFormButton(Btns);
      finally
        FreeAndNil(frmChild);
      end;
    end;
      

  4.   


    这个能不过啊   [Error] DllMain.dpr(54): Undeclared identifier: 'IsGetButtonList'[Error] DllMain.dpr(58): Undeclared identifier: 'GetChildFormButton'你的这个函数怎么用????????????
      

  5.   

    屏蔽cc.Parent:=Self使用
    windows.SetParent(cc.Handle, Handle);
      

  6.   


    你是要我这样写吗??
    function ABC(AppHandle:HWND; Btns: LongInt): LongInt; export; stdcall;
    begin
      Application.Handle:=AppHandle;
     // IsGetButtonList := True;
      fmDllMain:=TfmDllMain.Create(Application);
      try
       // fmDllMain.GetChildFormButton(Btns);
      finally
        FreeAndNil(fmDllMain);
      end;
    end;出错
      

  7.   

    dll 代码
    function fm: TForm; stdcall;
    begin
      Form2 := TForm2.Create(nil);
      Result := Form2;     
    end;
    exports fm name 'zjpfm';
    begin
    end.
    窗体代码var
      cc: TForm;
    begin
      cc:=TForm.Create(nil);
      cc := zjpFm;
      windows.SetParent(cc.Handle, Handle);
      cc.Visible := True;    
    end;
      

  8.   


    出现的错误是Access violation at address 007B24BD in module 'dllmain.dd'. read of address 0000000
      

  9.   

    这样写——————————————————————————
    function abc: TForm; stdcall;
    begin
      Result := TForm1.Create(Application);
    end;
      

  10.   

    dll窗体融合主程序窗体吗?cc:=zjpFm;
    cc.ParentWindow:=Self.handle;
    cc.align:=alClient;
    cc.icon.handle:=Application.icon.handle;
    cc.show;
      

  11.   

    另外,用主程序的application.handle替换dll的application.handle
      

  12.   

    引用方式不对,或者DLL中的接口不规范
      

  13.   

    这样写吧
    procedure VS_Createform(App:THandle);stdcall;
    begin
      Application.Handle := App;  
      if fmDllMain =nil then
      form1:=TfmDllMain.Create(application);
      form1.Position := poDesktopCenter;
      FSisonline := false;
      form1.show;
    end;
      

  14.   

    FSisonline := false;
    这句不要,这是我程序里面写的
      

  15.   


    你这是写在exe里面吧,试了,没用