看源码destructor TCustomForm.Destroy; begin if not (csDestroying in ComponentState) then GlobalNameSpace.BeginWrite; try if OldCreateOrder then DoDestroy; MergeMenu(False); if HandleAllocated then DestroyWindowHandle; Screen.RemoveForm(Self); FCanvas.Free; FIcon.Free; FreeAndNil(FActionLists); inherited Destroy; finally GlobalNameSpace.EndWrite; end; end;
begin
if not (csDestroying in ComponentState) then GlobalNameSpace.BeginWrite;
try
if OldCreateOrder then DoDestroy;
MergeMenu(False);
if HandleAllocated then DestroyWindowHandle;
Screen.RemoveForm(Self);
FCanvas.Free;
FIcon.Free;
FreeAndNil(FActionLists);
inherited Destroy;
finally
GlobalNameSpace.EndWrite;
end;
end;
oldcreateorder = False,则ondestroy在组件释放之后,否则,在组件释放之前。
因oldcreateorder属性的不同而不同
oldcreateorder = False,则ondestroy在组件释放之前,否则,在组件释放之后。to s11ss: 自己写个程序确认一下再否定我也不迟。
你的测试肯定有问题。
s11ss,你是对的,被测试代码误导了,组件的释放总是在ondetroy事件之后。