大家好,帮忙看一下,下面的代码出现一个问题,就是调用继承过来的表单后,引用dll,表单是能够打开的,并且在该表单中写的代码也是能够运行正常,但有些按钮继承的是父类中的代码,在这边就运行不了,并会造成程序死在那边动弹不得,因为是刚学着做dll,可能代码写的有问题,希望大家帮忙看一下,谢谢!其中frmBom的继承关系是:tfrom->tfrmBase->tfrmInfoBase->tfrmBaseInfoBase->tfrmBaseDefine->tfrmbom
下面是原码:
library technics_dll;uses
Forms,
Windows,
SysUtils,
Messages,
Dialogs,
Classes,
ActiveX,
DataModule in 'public\DataModule.pas' {dmClient: TDataModule},
Global in 'Public\Global.pas',
Base in 'public\Base.pas' {frmBase},
InfoBase in 'public\InfoBase.pas' {frmInfoBase},
BaseInfoBase in 'public\BaseInfoBase.pas' {frmBaseInfoBase},
BaseDefine in 'public\BaseDefine.pas' {frmBaseDefine},
pasBom in 'order\pasBom.pas' {frmBom},
pasBomcz in 'order\pasBomcz.pas' {frmBomcz},
pasBomdc in 'order\pasBomdc.pas' {frmBomdc},
pasBomzx in 'order\pasBomzx.pas' {frmBomzx};procedure techImport(psconn:pchar;sequ : Integer);stdcall;
begin
if not FileExists('public_dbcon.udl') and (psconn='') then
begin
messagebox(0,'数据库配置文件 pic.udl 不存在','错误',16);
exit;
end;
dmClient:=TdmClient.Create(dmClient);
dmClient.adocnequip_manage.Connected:=False;
dmClient.adocnequip_manage.ConnectionString:=psconn;
dmClient.adocnequip_manage.Connected:=True;
if sequ=1 then
begin
frmBom:=TfrmBom.Create(frmbom);
frmBom.ShowModal;
end; if sequ=2 then
begin
frmBomcz:=TfrmBomcz.Create(frmBomcz);
frmBomcz.ShowModal;
end; if sequ=3 then
begin
frmBomdc:=TfrmBomdc.Create(frmBomdc);
frmBomdc.ShowModal;
end; if sequ=4 then
begin
frmBomzx:=TfrmBomzx.Create(frmBomzx);
frmBomzx.ShowModal;
end;
end;
{$R *.res}
exports
techImport;
begin
end.
下面是原码:
library technics_dll;uses
Forms,
Windows,
SysUtils,
Messages,
Dialogs,
Classes,
ActiveX,
DataModule in 'public\DataModule.pas' {dmClient: TDataModule},
Global in 'Public\Global.pas',
Base in 'public\Base.pas' {frmBase},
InfoBase in 'public\InfoBase.pas' {frmInfoBase},
BaseInfoBase in 'public\BaseInfoBase.pas' {frmBaseInfoBase},
BaseDefine in 'public\BaseDefine.pas' {frmBaseDefine},
pasBom in 'order\pasBom.pas' {frmBom},
pasBomcz in 'order\pasBomcz.pas' {frmBomcz},
pasBomdc in 'order\pasBomdc.pas' {frmBomdc},
pasBomzx in 'order\pasBomzx.pas' {frmBomzx};procedure techImport(psconn:pchar;sequ : Integer);stdcall;
begin
if not FileExists('public_dbcon.udl') and (psconn='') then
begin
messagebox(0,'数据库配置文件 pic.udl 不存在','错误',16);
exit;
end;
dmClient:=TdmClient.Create(dmClient);
dmClient.adocnequip_manage.Connected:=False;
dmClient.adocnequip_manage.ConnectionString:=psconn;
dmClient.adocnequip_manage.Connected:=True;
if sequ=1 then
begin
frmBom:=TfrmBom.Create(frmbom);
frmBom.ShowModal;
end; if sequ=2 then
begin
frmBomcz:=TfrmBomcz.Create(frmBomcz);
frmBomcz.ShowModal;
end; if sequ=3 then
begin
frmBomdc:=TfrmBomdc.Create(frmBomdc);
frmBomdc.ShowModal;
end; if sequ=4 then
begin
frmBomzx:=TfrmBomzx.Create(frmBomzx);
frmBomzx.ShowModal;
end;
end;
{$R *.res}
exports
techImport;
begin
end.
解决方案 »
- 求教,什么情况下程序才会崩溃,不报错自动关闭?
- GetWindowThreadProcessId在哪个类里
- 使用LoadLibrary,GetProcAddress需要use哪个单元?
- 我需要重新构造一个类的Create函数,请问该如何操作?
- 请问Delphi7安装完成后,installshield是否也缺省安装,我咋没找到?
- 有关存成EXCEL死机的问题
- 如何用DELPHI实现代码控制TXT导入MSSQL2000...八百里加急!!!
- 如果我想获得textfile文件的长度或者行数,那么应该怎么办了
- 如何用Delphi实现类似VC开发环境的界面
- 图表DBCHART的series使用
- 如何用delphi访问office2007
- 关于一个输入查询问题.
begin
frmBom:=TfrmBom.Create(frmbom); //樂觀情況下,frmbom為nil,否則不堪設想。建議傳application
frmBom.ShowModal;
end; if sequ=2 then
begin
frmBomcz:=TfrmBomcz.Create(frmBomcz); //同上
frmBomcz.ShowModal;
end; if sequ=3 then
begin
frmBomdc:=TfrmBomdc.Create(frmBomdc); //同上
frmBomdc.ShowModal;
end; if sequ=4 then
begin
frmBomzx:=TfrmBomzx.Create(frmBomzx); //同上
frmBomzx.ShowModal;
end;
2、
1)、以下代碼寫在dll工程文件裡
procedure DLLEntryPoint(dwReason: DWord);
begin
case dwReason of
DLL_PROCESS_ATTACH:;//在這裡記錄原來的application
DLL_PROCESS_DETACH:;//在這裡還原原來的application
DLL_THREAD_ATTACH: ;
DLL_THREAD_DETACH: ;
end;
end; begin //以下兩行寫在dll工程文件自帶的begin..end
DllProc :=@DLLEntryPoint;
DLLEntryPoint(DLL_PROCESS_ATTACH);
end.
2)、你在調用函數時有傳application,這時你把dll的application的handle換成傳進來的那個application的handle
2、
1)、以下代碼寫在dll工程文件裡
procedure DLLEntryPoint(dwReason: DWord);
begin
case dwReason of
DLL_PROCESS_ATTACH:;//在這裡記錄原來的application
DLL_PROCESS_DETACH:;//在這裡還原原來的application
DLL_THREAD_ATTACH: ;
DLL_THREAD_DETACH: ;
end;
end;