我在BPL 建了一个窗体(名字叫FormSPGL) 一个Data Modle(名字叫BPL_DM)
Data Modle 有一个TSocketConnection (名字叫sconn1),里面的参数已经配置好了,当把Connected属性改成True 可以正确连接
问题来了:
首先我在FormSPGL引用了BPL_DM,并在窗体show事件里是这么写的:
BPL_DM.sconn1.Connected := True;这时候我主程序创建FormSPGL:代码如下
procedure TFormMain.cxTreeView1DblClick(Sender: TObject);
var
AClass: TPersistentClass;
PackageModule: HModule;
NewForm: TForm;
begin
PackageModule := LoadPackage('P.bpl')
{ TODO : 先检查包文件,有则加载,没有则报错!! }
if PackageModule <> 0 then
begin
AClass := GetClass('TFormSPGL' );
if AClass <> nil then
begin
NewForm := TComponentClass(AClass).Create(Application) as TForm;
NewForm.Position := poDesktopCenter;
NewForm.ShowModal;
end;
end;
end; 这段代码没有问题 (可看可不看)当程序运行到FormSPGL的 BPL_DM.sconn1.Connected := True;报出这样的错误
Access violation at address 0572C2E0 in module 'P_SPGL.bpl'. Read of address 00000060.我真的百思不得其解!
Data Modle 有一个TSocketConnection (名字叫sconn1),里面的参数已经配置好了,当把Connected属性改成True 可以正确连接
问题来了:
首先我在FormSPGL引用了BPL_DM,并在窗体show事件里是这么写的:
BPL_DM.sconn1.Connected := True;这时候我主程序创建FormSPGL:代码如下
procedure TFormMain.cxTreeView1DblClick(Sender: TObject);
var
AClass: TPersistentClass;
PackageModule: HModule;
NewForm: TForm;
begin
PackageModule := LoadPackage('P.bpl')
{ TODO : 先检查包文件,有则加载,没有则报错!! }
if PackageModule <> 0 then
begin
AClass := GetClass('TFormSPGL' );
if AClass <> nil then
begin
NewForm := TComponentClass(AClass).Create(Application) as TForm;
NewForm.Position := poDesktopCenter;
NewForm.ShowModal;
end;
end;
end; 这段代码没有问题 (可看可不看)当程序运行到FormSPGL的 BPL_DM.sconn1.Connected := True;报出这样的错误
Access violation at address 0572C2E0 in module 'P_SPGL.bpl'. Read of address 00000060.我真的百思不得其解!
Application.CreateForm(TForm1, Form1);
Form1.ShowModal;包的还是那个错误,BPL里的窗体是不是引用的?????????????????????