如何把窗体做进DLL呀,又怎么调用DLL窗体呢?各位大哥能贴一个简单的列子吗。谢谢。

解决方案 »

  1.   

    首先建立一个DLL工程,工程中附加你需要做进来的窗体对象的单元文件(也就是这个窗体的.PAS文件)
    其次在DLL中建立一个函数
    函数代码如下
    function xxxxx: integer; stdcall;
    begin
      .
      . 
      .
      from1.carete(nil);
      .
      .
      .
    end;
      

  2.   

    一个简单的例子。
    其实就是新建一个DLL工程,然后引用设计好的窗体,在DLL中创建该窗体即可。
      

  3.   

    dll 的dpr项目文件:
    library DLLForm;{ Important note about DLL memory management: ShareMem must be the
      first unit in your library's USES clause AND your project's (select
      Project-View Source) USES clause if your DLL exports any procedures or
      functions that pass strings as parameters or function results. This
      applies to all strings passed to and from your DLL--even those that
      are nested in records and classes. ShareMem is the interface unit to
      the BORLNDMM.DLL shared memory manager, which must be deployed along
      with your DLL. To avoid using BORLNDMM.DLL, pass string information
      using PChar or ShortString parameters. }uses
      SysUtils,
      Classes,
      Forms,
      ComObj,
      MainUnit in 'MainUnit.pas' {Form1};{$R *.res}
    //begin
    function ShowForm(aHandle: THandle; aCaption: PChar): Boolean;stdcall;
     var
       Form1: TForm1;
    begin
       Result := false;
       Application.Handle := aHandle;
       Form1 := TForm1.Create(Application);
       try
         Form1.Label1.Caption := aCaption;
         Form1.ShowModal;
       finally
         Form1.Free;
       end;
       Result := true;
    end;exports ShowForm;
    end.窗体文件:unit MainUnit;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, OleCtrls, Buttons;type
      TForm1 = class(TForm)
        Label1: TLabel;
        BitBtn1: TBitBtn;
        BitBtn2: TBitBtn;
        Map1: TMap;
        procedure BitBtn2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;implementation
      uses ComObj;{$R *.dfm}procedure TForm1.BitBtn2Click(Sender: TObject);
    begin
      Close;
    end;end.
      

  4.   

    http://www.2ccc.com/article.asp?articleid=2377
    上次忘了贴地址