C
cly402
Unregistered / Unconfirmed
GUEST, unregistred user!
请问怎么在主窗体中调用DLL中的子窗体?
我的一个主程序:
procedure TFrmMain.FormKeyPress(Sender: TObject; var Key: Char);
var
TIntFunc:function(AHandle:THandle;ACaption:string):LongInt;stdcall;
uRet:integer;
begin
Case key of
'1':
begin
Th:=LoadLibrary('ggxx.dll'); {装载DLL}
if Th>0 then
try
@TIntFunc:=GetProcAddress(Th,PChar('ShowForm'));
if Assigned(TIntFunc) then
begin
uRet:=TIntFunc(Application.Handle,IsCardIn);
end
else
ShowMessage('ShowForm函数没有找到');
finally
FreeLibrary(Th);
end;
end;
end;
end;
dll里的程序:
function ShowForm(ParentHandle:THandle;ACaption:String):LongInt;stdcall;
begin
Init_PubVar;
Application.handle :=Parenthandle;
if Not Assigned(FrmMainMenu) then
FrmMainMenu:=TFrmMainMenu.Create(Application);
Try
FrmMainMenu.Show;
Result:=LongInt(FrmMainMenu);
except
Result:=-1;
end;
end;
procedure UnLoadForm;StdCall;
var
i:integer;
begin
for i:=0 to Screen.FormCount -1 do
begin
Screen.Forms.Close;
end;
end;
为什么我在主窗体中一调用dll,子窗体不出现,而主窗体在屏幕上也没了?请求高手帮忙。
我的一个主程序:
procedure TFrmMain.FormKeyPress(Sender: TObject; var Key: Char);
var
TIntFunc:function(AHandle:THandle;ACaption:string):LongInt;stdcall;
uRet:integer;
begin
Case key of
'1':
begin
Th:=LoadLibrary('ggxx.dll'); {装载DLL}
if Th>0 then
try
@TIntFunc:=GetProcAddress(Th,PChar('ShowForm'));
if Assigned(TIntFunc) then
begin
uRet:=TIntFunc(Application.Handle,IsCardIn);
end
else
ShowMessage('ShowForm函数没有找到');
finally
FreeLibrary(Th);
end;
end;
end;
end;
dll里的程序:
function ShowForm(ParentHandle:THandle;ACaption:String):LongInt;stdcall;
begin
Init_PubVar;
Application.handle :=Parenthandle;
if Not Assigned(FrmMainMenu) then
FrmMainMenu:=TFrmMainMenu.Create(Application);
Try
FrmMainMenu.Show;
Result:=LongInt(FrmMainMenu);
except
Result:=-1;
end;
end;
procedure UnLoadForm;StdCall;
var
i:integer;
begin
for i:=0 to Screen.FormCount -1 do
begin
Screen.Forms.Close;
end;
end;
为什么我在主窗体中一调用dll,子窗体不出现,而主窗体在屏幕上也没了?请求高手帮忙。