Y
youou
Unregistered / Unconfirmed
GUEST, unregistred user!
MainForm.FormClose中主要是释放程序中使用的资源。
1.发现:
CLOSE时会调用MainForm.FormClose中的代码.
而Terminate不会!如果用它是不是会有内存泄漏的问题呢?
如果用HALT会有内存泄漏的问题吗?
procedure TApplication.Terminate;
begin
if CallTerminateProcs then PostQuitMessage(0);
end;
function CallTerminateProcs: Boolean;
var
PI: PTerminateProcInfo;
begin
Result := True;
PI := TerminateProcList; //这句主要是指什么啊?
while Result and (PI <> nil) do
begin
Result := PI^.Proc;
PI := PI^.Next;
end;
end;
procedure PostQuitMessage; external user32 name 'PostQuitMessage';
2.它们三个都会在TApplication.Run后调用到
procedure TForm1.FormDestroy(Sender: TObject);
begin
showMessage('aa');
end;
只是不同的是HALT会显示showMessage('aa')而其它两个不会?为什么呢?
3.可以说说下面的是什么意思吗?我看了一知半解的!
procedure TApplication.Run;
begin
FRunning := True;
try
AddExitProc(DoneApplication); //?????
if FMainForm <> nil then
begin
case CmdShow of
SW_SHOWMINNOACTIVE: FMainForm.FWindowState := wsMinimized; //让窗体最小化
SW_SHOWMAXIMIZED: MainForm.WindowState := wsMaximized; //最大化
end;
if FShowMainForm then
if FMainForm.FWindowState = wsMinimized then
Minimize else
FMainForm.Visible := True;
repeat
try
HandleMessage;
except
HandleException(Self);
end;
until Terminated;
end;
finally
FRunning := False;
end;
end;
1.发现:
CLOSE时会调用MainForm.FormClose中的代码.
而Terminate不会!如果用它是不是会有内存泄漏的问题呢?
如果用HALT会有内存泄漏的问题吗?
procedure TApplication.Terminate;
begin
if CallTerminateProcs then PostQuitMessage(0);
end;
function CallTerminateProcs: Boolean;
var
PI: PTerminateProcInfo;
begin
Result := True;
PI := TerminateProcList; //这句主要是指什么啊?
while Result and (PI <> nil) do
begin
Result := PI^.Proc;
PI := PI^.Next;
end;
end;
procedure PostQuitMessage; external user32 name 'PostQuitMessage';
2.它们三个都会在TApplication.Run后调用到
procedure TForm1.FormDestroy(Sender: TObject);
begin
showMessage('aa');
end;
只是不同的是HALT会显示showMessage('aa')而其它两个不会?为什么呢?
3.可以说说下面的是什么意思吗?我看了一知半解的!
procedure TApplication.Run;
begin
FRunning := True;
try
AddExitProc(DoneApplication); //?????
if FMainForm <> nil then
begin
case CmdShow of
SW_SHOWMINNOACTIVE: FMainForm.FWindowState := wsMinimized; //让窗体最小化
SW_SHOWMAXIMIZED: MainForm.WindowState := wsMaximized; //最大化
end;
if FShowMainForm then
if FMainForm.FWindowState = wsMinimized then
Minimize else
FMainForm.Visible := True;
repeat
try
HandleMessage;
except
HandleException(Self);
end;
until Terminated;
end;
finally
FRunning := False;
end;
end;