MDI窗体退出时提示出错?(急,一定给分)
tfm 2003-06-19 10:15:34 我做的程序是主窗体是MDIForm,然后每个MDIChild是用DLL的方式做的,每个字窗体的显示和关闭都没有问题,就是所有的字窗体都关闭后,关主窗体的时候,提示"内存读取出错,请问该怎么解决" ;我用的是静态调用;
代码如下:
DLL
library Project1;
{$R *.res}
var
DLLApp: TApplication;
DLLScr: TScreen;
procedure DLLEntryPoint(dwReason: DWORD);
begin
case dwReason of
DLL_PROCESS_ATTACH:
begin
DLLScr := Screen;
DLLApp := Application;
end;
DLL_PROCESS_DETACH:
begin
Screen := DllScr;
Application := DllApp;
end;
end;
end;
//// 运行DLL主窗口 //////////////////////////////////////
function RunApp(AApplication: TApplication; AScreen: TScreen):TForm1; stdcall;
begin
Screen := AScreen;
Application := AApplication;
Form1 := TForm1.Create(Application);
Form1.Show;
result:=form1;
end;
//////////////////////////////////////////////////////////////////////
exports
RunApp;
//////////////////////////////////////////////////////////////
begin
DLLProc := @DLLEntryPoint; //Assign the address of DLLEntryPoint to DLLProc
DLLEntryPoint(DLL_PROCESS_ATTACH); //Indicate that the DLL is attaching to the process
end.
主窗体是这样调用的
function RunApp(AApplication: TApplication; AScreen: TScreen;DBCON:TADOConnection):Tform; stdcall;external 'dll\project1.dll' ;
主窗体关闭时
procedure TF_Main.FormClose(Sender: TObject; var Action: TCloseAction);
var
i:integer;
begin
for I := MDIChildCount - 1 downto 0 do
begin
MDIChildren[I].Close;
MDIChildren[I].Free;
end;
end;
请各位帮忙看看