Alister wrote: > you might be able to go even one better by setting the Action > = caFree in OnClose and just use result := > Self.Create(nil).ShowModal = mrOK; removing the with, and > cutting the code from 6 lines to 1.
Even better, add a CloseAction property to your own TForm descendent and override DoClose to default to that property value thus avoiding even needing an OnClose handler. That's 0 lines of code :-) Although technically property value assignments are just lines of code in another (interpreted) guise. Jolyon is right about not using Free and using Release instead. What Release does is post a Windows message so that the call of Free on the form instance is deferred until the main Wndproc is back processing messages again by which time all event handlers are sure to have completed. Calling Free may 'seem' to work sometimes but a lurking 'use after Free' behaviour is only going to bite you in the ass eventually. And using caFree is quite safe since, despite the name, it actually calls Release (not Free) on the form instance. Cheers, Paul. _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe