怎么样调用Dll中的子窗体

解决方案 »

  1.   

    帮你顶一下,另再问一个问题,子窗体中如何调用上一级窗体的控件的值?如:
    From2.Edit1.Text:=From1.Edit1.Text; //这样肯定会出错的:(
      

  2.   

    你知道怎么样调用Dll中的“子”窗体,不是用ShowModel如是Show的方法?
      

  3.   

    给你一个调用用DLL的实例:
    (含有Form的DLL为:DLLShowForm.dll)uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        btnShowModal: TButton;
        BtnShow: TButton;
        procedure btnShowModalClick(Sender: TObject);
        procedure BtnShowClick(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    //静态引入DLL中的方法
    procedure ShowDLLModalForm(aHandle: THandle); stdcall external '..\DLLShowForm.dll';procedure ShowDLLForm(aHandle: THandle); stdcall external '..\DLLShowForm.dll';var
      Form1: TForm1;implementation{$R *.dfm}
    //调用DLL里输出的ShowDLLModalForm方法,模式显示窗口
    procedure TForm1.btnShowModalClick(Sender: TObject);
    begin
      ShowDLLModalForm(Application.Handle);
    end;//调用DLL里输出的ShowDLLForm方法,非模式显示函数
    procedure TForm1.BtnShowClick(Sender: TObject);
    begin
      ShowDLLForm(Application.Handle);
    end;end.
      

  4.   

    galxh(代码英雄)
    在unit2中uses unit1
      

  5.   

    再给你一个调用Form的DLL:(配合上例子)library DLLShowForm;uses
      SysUtils,
      Classes,
      DLLFrm in 'DLLFrm.pas' {frmDLL};
    {$R *.res}
    //输出ShowDLLModalForm,ShowDLLForm接口方法,以便外部程序调用
    exports
      ShowDLLModalForm, ShowDLLForm;
    begin
    end.
    unit DLLFrm;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TfrmDLL = class(TForm)
      private
        { Private declarations }
      public
        { Public declarations }
      end;{声明要引出的方法}
    procedure ShowDLLModalForm(aHandle: THandle); stdcall; 
    procedure ShowDLLForm(aHandle: THandle); stdcall;implementation{$R *.dfm}//模式显示窗口
    procedure ShowDLLModalForm(aHandle: THandle);
    begin
      Application.Handle := aHandle; 
      with TfrmDLL.Create(Application) do 
      begin
        try
          ShowModal; //模式显示窗体
        finally
          free;
        end;
      end;
    end;
    //非模式显示窗口
    procedure ShowDLLForm(aHandle: THandle);
    begin
      Application.Handle := aHandle; 
      with TfrmDLL.Create(application) do 
        Show; 
    end;
    end./////具体其他代码在你的Form中写。///