Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / August 2003

Tip: Looking for answers? Try searching our database.

Closing Dialogs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Graham - 27 Aug 2003 11:27 GMT
I have an application which has 8 dialog windows, some
have timed updates on them (via a timer).

What is the best way to terminate the application; i.e.
what needs to be done on the main Exit button of the
application; close down other dialogs etc, kill the timers
etc?
Kevin McNeish [C# MVP] - 27 Aug 2003 14:48 GMT
> I have an application which has 8 dialog windows, some
> have timed updates on them (via a timer).
[quoted text clipped - 3 lines]
> application; close down other dialogs etc, kill the timers
> etc?

I solve this problem by means of a Form Manager. In my form base class
(subclassed from System.Windows.Forms.Form), I have placed code in the
constructor that registers each form with the Form Manager (the Form Manager
has a static RegisterForm method that is called). You can either have the
Form Manager store a reference to each form in a collection (reference
should be removed when a form is closed), or you can register the forms as
event handlers of Form Manager events (again, forms should be unregistered
when the form closes).

You can then add a CloseAllForms method to your Form Manager. This method
can call a special "Shutdown" or "Close" method on all active forms (or
raise an event if you're going with that model). Within each form you can
place the intelligence that knows how to shut down that particular form.

I have this working in two different modes...one mode checks if the user has
pending changes and asks if they want to save them. Another "brute force"
mode simply ignores pending changes and closes the forms down.

Regards,
Kevin McNeish
.NET /C# MVP
Chief Software Architect, Mere Mortals .NET Framework
www.oakleafsd.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.