您的位置:首页 > 编程语言 > Delphi

Delphi调用DLL文件里的窗体

2010-12-30 03:37 302 查看
Delphi调用DLL文件里的窗体

在我们写程序时候,有些窗体要重复使用,最好就是把这些窗体写到一个DLL文件里去,这样就比较方便调用,下面的演示如何调用DLL文件里的窗体。

DLL文件

{*******************************************************}
{                                                       }
{       测试调用Dll里的窗体                               }
{                                                       }
{                                                       }
{*******************************************************}
library TestDll;
uses
SysUtils, Classes, U_Login in 'U_Login.pas' {Frm_Login};
{$R *.res}

procedure showlogin(); stdcall;
//起动登录窗体
beginFrm_Login := TFrm_Login.Create(nil);
try
Frm_Login.ShowModal;
except
Frm_Login.Free;
end;
end;
exports //导出函数和过程名
showlogin;
begin
end.
主程序源码
{*******************************************************}
{                                                       }
{       测试调用Dll里的窗体                               }
{                                                       }
{                                                       }
{*******************************************************}
unit U_main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs;
type
TFrm_Main = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_Main: TFrm_Main;
implementation
{$R *.dfm}

procedure showlogin(); stdcall; external 'TestDll.dll';
//声名调用的过程名的DLL文件

procedure TFrm_Main.FormCreate(Sender: TObject);
begin
showlogin(); //调用登录窗口
end;
end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: