Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RETURN .F. in form init event

Status
Not open for further replies.

StewartUK

Programmer
Feb 19, 2001
860
GB
I guess this is pretty obvious now I realise it, but I found out today that if you have the line RETURN .F. in the Init event of a form (which means that the Initialisation is stopped & so the form never appears) the Destroy event of the form does not run.


Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Stewart,

No, I don't think it's obvious. It caught me out some tine ago.

By the way, it's not just the Destroy that fails to run. Unload doesn't run either. What's more, if the form is modal, it means that you can't return a result (since it's the Unload that is responsible for doing that). (Or, to be more precise, the returned result will always be .F.).

This is certainly worth knowing about. Thanks for posting it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Yes, it's an important observation. In some frameworks you have to either call Destroy or CleanUp method yourself to avoid dangling object references.
 
That's why it's better to prevent form creation in Load() when needed. That doesn't run Destroy() or Unload() too, but you may not already have loaded/added some objects, you need to destroy again.

It's of course not possible in cases, where you can only decide from the passed in parameters in Init().

Me thinks it's documented behaviour.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top