一DLL中有三个窗体,tj_form,tj_cx,form12.现双击tj_form上的一个按钮.调用TJ_CX窗体.在tj_cx的Ttj_cx.FormShow中调用了.cxtextedit4.text:=tj_form.cxtextedit7.text.处理完后又反回给了tj_form.cxtextedit7.text:=cxtextedit4.text;没有在tj_cx.formshow加入cxtextedit4.text:=tj_form.cxtextedit7.text时一正常,一但调用tj_form.cxtextedit7.text时就报错:access violation at address 024db252 in module 'dll.dll'.read of address 00000488.,反回给tj_form.cxtextedit7.text的值时也是如此.我现在这样:aa_7等于tj_form上的cxtextedit7.text的值.
var tj_cx:Ttj_cx;begin tj_cx:=ttj_cx.Create(nil);
tj_cx.cxTextEdit4.text:=aa_7;
tj_cx.ShowModal;
tj_cx.Free;
这样可以传过去,但处理完后还要回到tf_form.cxtextedit7.text中,一样的报错,请那位高手多多指教?
var tj_cx:Ttj_cx;begin tj_cx:=ttj_cx.Create(nil);
tj_cx.cxTextEdit4.text:=aa_7;
tj_cx.ShowModal;
tj_cx.Free;
这样可以传过去,但处理完后还要回到tf_form.cxtextedit7.text中,一样的报错,请那位高手多多指教?
begin
if (cxTextEdit5.Text<>'') or (cxTextEdit5.Text<>'0') then
begin
try
tj_form.cxTextEdit7.text:=FloatToStr(roundto(strtofloat(cxTextEdit5.Text),-3));
MessageBox(Self.Handle,'单价计算成功.','提示',MB_ICONINFORMATION and MB_ICONASTERISK);
Close;
except MessageBox(Self.Handle,'单价计算失败.','错误',MB_iconstop);
Exit;
end;
end;
end;
这个DLL只前一直在用,没有什么问题,最近跟据要求才添加了一个tj_cx窗体,结果就这样了.
tj_form.cxTextEdit7.text:=FloatToStr(roundto(strtofloat(cxTextEdit5.Text),-3));
MessageBox(Self.Handle,'单价计算成功.','提示',MB_ICONINFORMATION and MB_ICONASTERISK);
Close;
except MessageBox(Self.Handle,'单价计算失败.','错误',MB_iconstop);
Exit;
end;
问题就在这里了.调用该DLL后单击Ttj_cx.cxButton1Click反回的是'单价计算失败.'
DLL:
private
aa_1,aa_2,aa_3,aa_4,aa_5,aa_6,username,dl_bm,dl_zw:string;
xjc,xjc1,jjc,jjc1:Real;
{ Private declarations }
public
aa_7:string;
{ Public declarations }
end;var
tj_form: Ttj_form;function showform(ahandle:thandle; acaption:pchar;username,dl_bm,dl_zw:string):tdatetime; stdcall;implementationuses Unit2, SGDGD_TJDY;{$R *.dfm}
function showform(ahandle:thandle;acaption:pchar;username,dl_bm,dl_zw:string):tdatetime;stdcall;
var
tj_form:ttj_form;
begin
application.Handle:=ahandle;
tj_form:=ttj_form.Create(application);
try
tj_form.Caption:='订购单_添加';
tj_form.username:=username;
tj_form.dl_bm:=dl_bm;
tj_form.dl_zw:=dl_zw;
tj_form.ShowModal;
result:=now;
finally
tj_form.Free;
end;
end;
主程序:
procedure TFrame5.BitBtn1Click(Sender: TObject);
var
libhandle:thandle;
showform:tshowform;
begin
username:=form1.dl_xm;
dl_bm:=form1.dl_bm;
dl_zw:=form1.dl_zw;
if ((dl_bm='生管')and ((dl_zw='采购')or(DL_ZW='主管'))) or (DL_BM='公司') then
begin
libhandle:=loadlibrary('dll.dll');
try
if libhandle=0 then
raise edllloaderror.Create('dll不存在!');
@showform:=getprocaddress(libhandle,'showform');
if not (@showform=nil) then
showform(application.MainForm.handle,pchar(caption),username,dl_bm,dl_zw)
else
raiselastwin32error;
finally
freelibrary(libhandle);
end;
end
else
begin
messagebox(0,'您没有权限进入!','提示',mb_iconstop);
exit;
end;