我如何把一form变成一个DLL(20分)

  • 主题发起人 主题发起人 why_119
  • 开始时间 开始时间
W

why_119

Unregistered / Unconfirmed
GUEST, unregistred user!
我如何把一form变成一个DLL
变完后如何调用?多谢大家了.........
 
就是写DLL吗,在其中包含FORM,是不是这个意思。
论坛里面多。
 
dcr文件改成下面的样式,ctrl+F9编译......
Library Project1;

uses
Forms,
Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}
{
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
}
procedure Sample(s:string);
begin
Application.CreateForm(TForm1, Form1);
Form1.ShowModal;
Form1.Free;
end;

exports Sample;
end.
 
和一般的程序没什么两样,只不过NEW的不是项目而,是DLL,我建议你到书店化10分钟翻翻就会了
将DELPHI DLL的书都有讲
 
给你一段代码你参考一下:
unit DLLFrm;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, Calendar;

type
TDLLForm = class(TForm)
calDllCalendar: TCalendar;
procedure calDllCalendarDblClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

function ShowCalendar(AHandle:THandle;ACaption:String):TDateTime;stdcall;

implementation

{$R *.dfm}
function ShowCalendar(AHandle:THandle;ACaption:String):TDateTime;
var
DLLForm: TDLLForm;
begin
Application.Handle:=AHandle;
DLLForm:=TDLLForm.Create(Application);
try
DLLForm.Caption:=ACaption;
DLLForm.ShowModal;
Result:=DLLForm.calDllCalendar.CalendarDate;
finally
DLLForm.Free;
end;
end;

procedure TDLLForm.calDllCalendarDblClick(Sender: TObject);
begin
close;
end;

end.
 
后退
顶部