Are all these forms pre-created at app startup?
 
I hope not, as I have found the dynamic creation and disposal of forms to work 
best for me.
 
If you're not sure if a form is in memory when you try to close it, just do 
some checking first to make sure the form needs closing/freeing:
 
If Assigned(MyTargetForm) then
  begin
    MyTargetForm.Close;
    MyTargetForm.Free;
  end;
This way any additional calls you make to close the form won't get executed 
because the form will have already been freed.
 
I hope I understood what you were asking...
 
Please let me know if this helps, or if not, what I misunderstood...
 
 



To: advanced_del...@yahoogroups.comfrom: jer...@ninprodata.comdate: Fri, 2 Jan 
2009 17:54:24 -0800Subject: [advanced_delphi] managing multiple forms of mixed 
types on close




I’ve been wrestling with this issue for a long time, each time I think I have 
it fixed, it stays that way a little while, then someone figures out another 
way to blow things up.  Here’s the deal:
The app has a main form from which another form is shown non-modally.  From 
this 2nd form, yet a 3rd form can be shown, also non-modally.  When the main 
form is closed, there is a bit of code that runs through the open forms and 
closes them.  The 2nd form has a similar bit of code that cleans up any stray 
3rd forms.  The problem is, if a user closes the main form when the 2nd form 
and its spawned 3rd form(s) are open, I’m closing the 3rd one(s) twice.
Now, I can probably figure out something to work around the problem in this 
specific case, but I really think my model is faulty.  I need a perfected 
pattern, if you will.  Has anyone solved this issue or found a pattern that 
works?  I’ve been experimenting with windows messaging lately, and that really 
works well for what it does.  And it sounds like it might be a good tool here, 
but I haven’t figured out how to apply it yet.
Jeremy
 





_________________________________________________________________
It’s the same Hotmail®. If by “same” you mean up to 70% faster.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_broad1_122008

Reply via email to