刚才说错了,下面那一段是项目文件,不是单元。
再看这个:
下面这具程序是把一个普通的窗体项目做成了一个DLL(如果不做成DLL它就是一个执行
文件),调用它的程序只需要调用“RunForm“这个过程就可以了
////////////////这是项目文件//////////////////
Library FormDll;
uses
Forms,
DF1 in 'DF1.pas' {Form1};
procedure RunForm;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end;
exports
RunForm;
end.
////////////////这是项目的窗体单元://////////////////////
unit DF1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
MessageBox(Handle,PChar('Good by, '+Edit1.Text),'DLL',MB_ICONINFORMATION+MB_OK);
Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label2.Caption := FormatDateTime(LongDateFormat,Date);
Label2.Left := (Form1.Width div 2)-(Label2.Width div 2);
end;
end.