我在DLL中的代码是
procedure basy_show(ParentApplication: HWND; ParentForm: TForm);export; stdcall;begin
Application.Handle:=ParentApplication;
BaForm:=Tbaform.Create(application.MainForm);
BaForm.Parent:=ParentForm;
BaForm.Show;
end;调用方式是:procedure TMenuForm.RzToolbarButton1Click(Sender: TObject);
begin
basy_show(application.Handle,self);
end;目前现象是,一执行调用操作,子窗口快速显示一下就自动消失了,但是还是驻留在内存中,退出程序时报错想尽办法解决不了,在这里求援了
procedure basy_show(ParentApplication: HWND; ParentForm: TForm);export; stdcall;begin
Application.Handle:=ParentApplication;
BaForm:=Tbaform.Create(application.MainForm);
BaForm.Parent:=ParentForm;
BaForm.Show;
end;调用方式是:procedure TMenuForm.RzToolbarButton1Click(Sender: TObject);
begin
basy_show(application.Handle,self);
end;目前现象是,一执行调用操作,子窗口快速显示一下就自动消失了,但是还是驻留在内存中,退出程序时报错想尽办法解决不了,在这里求援了
解决方案 »
- 请教一个richedit设置显示文字颜色的问题
- 应用程序进程问题,苦恼!!!!!!
- 如何用TDBGrid 修改表中的内容?
- 一个Access数据库的查询问题,帮忙看看!
- 高手求救啊,为什么远程桌面连接,无法执行服务器上的应用程序!!!!
- 将windows字体改大之后,控件对不上位了
- ··真正的程序员用VC++,聪明的程序员用delphi,那PB呢?··
- DBCombobox数据库存取的问题?
- 高手指教,delphi中怎么引用api函数terminateprocess?
- 有哪位高手愿意当我的老师,我己经学了将近两个月,只能编些小程序,我想请一位能让我提问的老师,我一定好好学,要绝对的高手,因为名师出高徒?
- 系统上装有Delphi,在IE6出错时会自动跳出Delphi调试,能不能禁止调试啊??
- 如何得到某字段的最大值.
procedure TFmMain.LoadDllForm(FileName: String);
begin
LibHandle := LoadLibrary(Pchar(FileName));
if LibHandle = 0 then
raise Exception.Create('模块装载失败,模块名:' + FileName);
@ShowChild := GetProcAddress(LibHandle, 'ShowChild');
if @ShowChild <> nil then
begin
ShowChild(@Application);
end
else
raise Exception.Create('入口函数出错!');
end;
Dll程序输出函数:
procedure ShowChild(pMainApp:Pointer);stdcall;
var
pForm:^TForm;
begin
Application.Handle:=TApplication(Pointer(pMainApp^)).Handle;
pForm:[email protected];
pForm^:= TApplication(Pointer(pMainApp^)).MainForm; proc := TProc.Create; //创建业务对象 将在FmMain.destroy 中释放);
fmMain:=TfmMain.Create(nil);
//*******************************
fmMain.FormStyle := fsMDIChild;
fmMain.WindowState := wsMaximized;//保证主窗体以最大化方法显示
//*******************************
fmMain.show;
end;
procedure DLLUnloadProc(Reason: Integer); register;
begin
if Reason = 0 then
begin
Application.CancelHint;
application.Handle := 0;
if Assigned(fmMain) then FreeAndNil(fmMain);
end;
end;exports
ShowChild;begin
DllProc := @DLLUnloadProc;
end.不过你要自己考虑将来的每个模块的释放,最好在主程序中有个维护模块加载状态的List,程序退出时,全部释放。
proc := TProc.Create; //创建业务对象 将在FmMain.destroy 中释放);
中的proc和TProc.Create是从何而来,
这是我从我们的系统中摘出来的代码,这是个业务类,没去掉。
以为你能看出来,呵呵