主程序form1设为fsMDIForm,然后调用dll中的窗体(fsMDIChild),并设成主程序的子窗体,不成功,请教各位高手了...谢谢.
主程序:
   private
    dl_xm,dl_qx,joinstr:string;
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  kc_handle:THandle;implementation{$R *.dfm}procedure TForm1.FormResize(Sender: TObject);
beginImage1.Left:=(form1.Panel1.Width-form1.Image1.Width)    div    2;
Image1.Top:=(form1.Panel1.Height-image1.Height)    div    2;
end;procedure TForm1.N5Click(Sender: TObject);
var
  kc:procedure(dl_xm,joinstr,dl_qx:string);stdcall;
begin
  kc_handle:=LoadLibrary(PChar('kcsh_dll.dll'));
  if kc_handle<=0 then
    begin
      Application.MessageBox('动态库不存在!','提示',64);
      exit;
    end
   else
    begin
      try
        @kc:=GetProcAddress(kc_handle,'kc_tj');
         kc(Form1.dl_xm,Form1.joinstr,form1.dl_qx);
      except
        Application.MessageBox('动态库加载失败!','提示',64);
        exit;
      end;
    end;
end;procedure TForm1.FormShow(Sender: TObject);
begin
 dl_xm:='123';
 dl_qx:='234';
 joinstr:='345';
end;end.dll如下:
type
  Tkcsh_tj = class(TForm)
  private
    dl_xm,joinstr,dl_qx:string;
    { Private declarations }
  public
    { Public declarations }
  end;var
 kcsh_tj:Tkcsh_tj;
 procedure kc_create;
 procedure kc_free;
 procedure kc_tj(dl_xm:string;joinstr:string;dl_qx:string);stdcall;
implementation{$R *.dfm}
 procedure kc_create;
  begin
    kcsh_tj:=Tkcsh_tj.Create(Application.MainForm);
  end;
 procedure kc_free;
  begin
    if Assigned(kcsh_tj) then kcsh_tj.Free;
  end;
 procedure kc_tj(dl_xm,joinstr,dl_qx:string);stdcall;
  begin
    try
      kc_create;
      kcsh_tj.dl_xm:=dl_xm;
      kcsh_tj.joinstr:=joinstr;
      kcsh_tj.dl_qx:=dl_qx;
      kcsh_tj.Show;
      finally
        kc_free;
  end;
  end;
end.

解决方案 »

  1.   

    procedure kc_create; 
      begin 
        kcsh_tj:=Tkcsh_tj.Create(Application.MainForm); 
      end
    这里写错了,是:kcsh_tj:=Tkcsh_tj.Create(Application); 
      

  2.   

    kcsh_tj.Parent := Application.MainForm;
    未经验证,试试
      

  3.   

    http://topic.csdn.net/u/20091030/14/cacff462-27db-4e35-ab57-016af102a910.html
    这个帖子,楼主已经实现
      

  4.   


    dll中  frmDLL dll名字 
    procedure SynAPP(App: THandle); stdcall;
    begin
      Application.Handle := App;
    end; 
    procedure ShowForm; stdcall;
    begin
      try
        frmDLL := TfrmDLL.Create(Application);
        try
          frmDLL.ShowModal;
        finally
          frmDLL.Free;
        end;
      except
        on E: Exception do
          MessageDlg('Error in DLLForm: ' +
            E.Message, mtError, [mbOK], 0);
      end;
    end;library MyFirstDLL;
    uses
      SysUtils,
      Classes,
      frm_DLL in 'frm_DLL.pas' {frmDLL};{$R *.res}
      exports
      SynAPP, ShowForm;
    begin
    end.
    SynApp(Application.Handle ); {首先必须调用这个过程,并且使用Application 的句柄作为参数}
    ShowForm ;
      

  5.   

    TO:kobaer
     是不是可以这样理解,就是把你的.synapp,和showform替换我的kcsh_create和kcsh_tj呀,如可能,是否可以帮我修改我的代码按你的方法?先谢了.