![]() |
AW: Try-finally und modalresult
OnCreate -> OnDestroy
OnShow -> OnClose
Delphi-Quellcode:
F := TMyForm.Create(x);
try F.Show; F.Close; F.Show; // peng ... F.ShowModal; F.ShowModal; // peng ... finally F.Free; end; |
AW: Try-finally und modalresult
On -> Off (SCNR^^)
|
AW: Try-finally und modalresult
Zitat:
Zitat:
Delphi-Quellcode:
unit Foo
interface function Foo_ShowModal: integer; implementation function Foo_ShowModal: integer; begin with TFoo.Create(Application) do try Result := ShowModal; finally Release; end; end; |
AW: Try-finally und modalresult
Die Standardaktion im OnClose ist nicht freigeben (caFree), sondern verstecken (caHide). Das bedeutet, dass das Fenster auch nach einem Close weiterlebt, nur eben nicht sichtbar. Wenn man da also etwas freigibt, was man im OnCreate erzeugt hat, fängt man sich einen wilden Zeiger ein, was bei künftigen Zugriffen darauf dann in einer AV endet.
|
AW: Try-finally und modalresult
Zitat:
|
AW: Try-finally und modalresult
Finally wird immer ausgeführt. Sogar das hier funktioniert:
Delphi-Quellcode:
try
exit; finally ShowMessage('Foobar'); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:18 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz