手机
当前位置:查字典教程网 >编程开发 >Delphi >delphi中一个值得大家来考虑的DLL问题
delphi中一个值得大家来考虑的DLL问题
摘要:以下是我的原代码:=============================================================...

以下是我的原代码:

==========================================================================================

DPR单元代码

programMdiform;

uses

Forms,

UMdiformin´UMdiform.pas´{Mainform},

UDMin´UDM.pas´{GlobalDM:TDataModule},

UFunin´UFun.pas´;

{$R*.res}

begin

Application.Initialize;

Application.CreateForm(TMainform,Mainform);

Application.Run;

end.

===============================================================================================

主窗体代码:

unitUMdiform;

interface

uses

Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,

Dialogs,Udm,StdCtrls;

type

TMainform=class(TForm)

Button1:TButton;

procedureButton1Click(Sender:TObject);

procedureFormCreate(Sender:TObject);

private

{Privatedeclarations}

public

MyHandle:HWND;

{Publicdeclarations}

end;

var

Mainform:TMainform;

type

T_ShowTestMng=function(varadm:TMainform):Boolean;StdCall;

implementation

{$R*.dfm}

procedureTMainform.Button1Click(Sender:TObject);

var

Lib_:THandle;

_ShowTestMng:T_ShowTestMng;

begin

Lib_:=LoadLibrary(pchar(´MdiChild.dll´));

try

@_ShowTestMng:=GetProcAddress(Lib_,´_ShowTestMng´);

ifnot(@_ShowTestMng=nil)then

_ShowTestMng(Mainform);

finally

FreeLibrary(Lib_);

end;

end;

procedureTMainform.FormCreate(Sender:TObject);

begin

MyHandle:=Application.Handle;

end;

end.

==============================================================================================

子窗体DLL代码:

libraryMdiChild;

uses

ShareMem,

UMdiform,//此单元为父窗体单元,在顶目设置中我已经设置了搜索此单元在路径。

Forms,

SysUtils,

Classes,

UChildin´UChild.pas´{FrmChild};//FrmChild子窗体的FormStyle属性为FsMDIChild

{$R*.res}

function_ShowTestMng(varadm:TMainform):Boolean;StdCall;

begin

result:=true;

Application.Handle:=adm.MyHandle;

Application.CreateForm(TFrmChild,FrmChild);//程序就出错在此:出错原因是:Cannotcreateform.NoMDIFormsarecurrentlyactive.

FrmChild.Show;

end;

exports

_ShowTestMng;

end.

【delphi中一个值得大家来考虑的DLL问题】相关文章:

在Delphi实现在数据库中存取图像的图文演示无错

delphi程序全屏显示无标题栏覆盖整个屏幕(适合屏保)

Delphi 生成excel中饼图的实例代码

Delphi实例演示Rect、Bounds生成TRect的区别

Delphi中对时间操作方法汇总

Delphi实现毫秒级别的倒计时实例代码

Delphi建立、读取、存贮INI文件的方法《一》

初探Delphi中的插件编程

TImage组件实现保存图片到Stream

Delphi7中群发Email邮件的方法

精品推荐
分类导航