Z
zhczm
Unregistered / Unconfirmed
GUEST, unregistred user!
我做了两个独立的Dll窗体A,B
我要分别同时动态载入两个动态建立的页,但是有如下问题:
1,不能同时载入
2 ,必须把上一个句柄完全卸载,才可以载入下一个Dll窗体
3 在Dll窗体A不能动态载入Dll窗体B
我的载入程序:
private
TT : TrzTabSheet;
TP : TrzPageControl;
hd: THandle;
Dll_hd: THandle;
TFrm:TFormClass;
frm:TForm;
{ Private declarations }
public
{ Public declarations }
end;
procedure Tf_auto.RzButton2Click(Sender: TObject);
type TGetDllForm_user=function():TFormClass;stdcall;
var fm:TGetDllForm_user;
tf:tfarproc;
i:integer;
s,bs:string;
begin
s:='user1';
if tp=nil then
begin
tp:= TrzPageControl.Create(self);
tp.Parent :=panel1;
tp.Align:=alclient;
tp.TabOrientation:=toBottom;
end;
bs:='A';
if tp.PageCount>0 then
for i:=0 to tp.PageCount-1do
begin
if trim(tp.Pages.Caption)=s then
begin
tp.ActivePageIndex:=i;
bs:='';
break;
end;
end;
if bs='A' then
begin
tt:= TrzTabSheet.Create(tp);
tt.Parent:=tp;
//tt.Visible := True;
tt.Caption :=s;
tt.PageControl :=tp;
tt.Align:=alclient;
tp.ActivePageIndex:=tt.PageIndex;
Dll_hd :=LoadLibrary('userdll1.dll');
try
tf:=GetProcAddress(Dll_hd, 'GetDllForm_user');
if tf = nil then
Abort;
fm:=TGetDllForm_user(tf);
Tfrm:=fm();
frm:=tfrm.Create(tt);
frm.Parent:=tt;
frm.Align:=alclient;
frm.Show;
except raise;
//finally freelibrary(hd);
//
end;
end;
end;
procedure Tf_auto.RzButton3Click(Sender: TObject);
type TGetDllForm_user=function():TFormClass;stdcall;
var fm:TGetDllForm_user;
tf:tfarproc;
i:integer;
s,bs:string;
begin
s:='user';
if tp=nil then
begin
tp:= TrzPageControl.Create(self);
tp.Parent :=panel1;
tp.Align:=alclient;
tp.TabOrientation:=toBottom;
end;
bs:='A';
if tp.PageCount>0 then
for i:=0 to tp.PageCount-1do
begin
if trim(tp.Pages.Caption)=s then
begin
tp.ActivePageIndex:=i;
bs:='';
break;
end;
end;
if bs='A' then
begin
tt:= TrzTabSheet.Create(tp);
tt.Parent:=tp;
//tt.Visible := True;
tt.Caption :=s;
tt.PageControl :=tp;
tt.Align:=alclient;
tp.ActivePageIndex:=tt.PageIndex;
Dll_hd :=LoadLibrary('userdll.dll');
try
tf:=GetProcAddress(Dll_hd, 'GetDllForm_user');
if tf = nil then
Abort;
fm:=TGetDllForm_user(tf);
Tfrm:=fm();
frm:=tfrm.Create(tt);
frm.Parent:=tt;
frm.Align:=alclient;
frm.Show;
except raise;
//finally freelibrary(hd);
//
end;
end;
end;
我要分别同时动态载入两个动态建立的页,但是有如下问题:
1,不能同时载入
2 ,必须把上一个句柄完全卸载,才可以载入下一个Dll窗体
3 在Dll窗体A不能动态载入Dll窗体B
我的载入程序:
代码:
TT : TrzTabSheet;
TP : TrzPageControl;
hd: THandle;
Dll_hd: THandle;
TFrm:TFormClass;
frm:TForm;
{ Private declarations }
public
{ Public declarations }
end;
procedure Tf_auto.RzButton2Click(Sender: TObject);
type TGetDllForm_user=function():TFormClass;stdcall;
var fm:TGetDllForm_user;
tf:tfarproc;
i:integer;
s,bs:string;
begin
s:='user1';
if tp=nil then
begin
tp:= TrzPageControl.Create(self);
tp.Parent :=panel1;
tp.Align:=alclient;
tp.TabOrientation:=toBottom;
end;
bs:='A';
if tp.PageCount>0 then
for i:=0 to tp.PageCount-1do
begin
if trim(tp.Pages.Caption)=s then
begin
tp.ActivePageIndex:=i;
bs:='';
break;
end;
end;
if bs='A' then
begin
tt:= TrzTabSheet.Create(tp);
tt.Parent:=tp;
//tt.Visible := True;
tt.Caption :=s;
tt.PageControl :=tp;
tt.Align:=alclient;
tp.ActivePageIndex:=tt.PageIndex;
Dll_hd :=LoadLibrary('userdll1.dll');
try
tf:=GetProcAddress(Dll_hd, 'GetDllForm_user');
if tf = nil then
Abort;
fm:=TGetDllForm_user(tf);
Tfrm:=fm();
frm:=tfrm.Create(tt);
frm.Parent:=tt;
frm.Align:=alclient;
frm.Show;
except raise;
//finally freelibrary(hd);
//
end;
end;
end;
procedure Tf_auto.RzButton3Click(Sender: TObject);
type TGetDllForm_user=function():TFormClass;stdcall;
var fm:TGetDllForm_user;
tf:tfarproc;
i:integer;
s,bs:string;
begin
s:='user';
if tp=nil then
begin
tp:= TrzPageControl.Create(self);
tp.Parent :=panel1;
tp.Align:=alclient;
tp.TabOrientation:=toBottom;
end;
bs:='A';
if tp.PageCount>0 then
for i:=0 to tp.PageCount-1do
begin
if trim(tp.Pages.Caption)=s then
begin
tp.ActivePageIndex:=i;
bs:='';
break;
end;
end;
if bs='A' then
begin
tt:= TrzTabSheet.Create(tp);
tt.Parent:=tp;
//tt.Visible := True;
tt.Caption :=s;
tt.PageControl :=tp;
tt.Align:=alclient;
tp.ActivePageIndex:=tt.PageIndex;
Dll_hd :=LoadLibrary('userdll.dll');
try
tf:=GetProcAddress(Dll_hd, 'GetDllForm_user');
if tf = nil then
Abort;
fm:=TGetDllForm_user(tf);
Tfrm:=fm();
frm:=tfrm.Create(tt);
frm.Parent:=tt;
frm.Align:=alclient;
frm.Show;
except raise;
//finally freelibrary(hd);
//
end;
end;
end;