Jeremy: The only other thought I have about this is that if you make sure that you've assigned both the proper owners and parents for the new forms you create, sub forms, even non-modal ones, should get closed when their parents/owners get closed... Are you assigning both owners and parents to the new forms you create?
To: advanced_del...@yahoogroups.comfrom: jer...@ninprodata.comdate: Fri, 2 Jan 2009 20:46:12 -0800Subject: RE: [advanced_delphi] managing multiple forms of mixed types on close No, not created at startup. Also, I long ago stopped accessing form variables in units outside their home. In fact if you look on Borland’s newsgroups you’ll see that the experts suggest that using class procedures and removing the Delphi generated frmxxx vars is a good practice. But anyway, checking Assigned before closing is an interesting idea, it’s just that the difference between nil and not Assigned has always given me a headache. From: advanced_delphi@yahoogroups.com [mailto:advanced_del...@yahoogroups.com] On Behalf Of Sean RobertsSent: Friday, January 02, 2009 6:58 PMTo: advanced_del...@yahoogroups.comsubject: RE: [advanced_delphi] managing multiple forms of mixed types on close 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. Get your account now. _________________________________________________________________ Life on your PC is safer, easier, and more enjoyable with Windows Vista®. http://clk.atdmt.com/MRT/go/127032870/direct/01/