Shell Form Closing Event

Topics: CAB & Smart Client Software Factory
May 11, 2006 at 10:27 AM
originally posted by: saregama

I have a shell application that hosts different modules. Each module contains different workitems that are hosted through a deck workspace on the shell. When a user accidently closes the main shell form, I would like to have the capability of prompting the user about any incomplete usecases that needs to be completed before closing the application. I could trap the onterminate() event on each workitem to perform this check and prevent the workitem from disposing/terminating, but how do I prevent the shell form from closing. I tried to capture the form_closing event, but this event gets called before the workitem is terminated.
Any ideas is appreciated.
May 12, 2006 at 2:38 AM
originally posted by: PJackson

We took a different approach to this problem. We created an ISavable interface with a RequiresSave property and a Save method. When the shell form is closing we query the Items collections, starting with RootWorkItem, and if any ISavable Item "RequiresSave", then we prompt the user -- if they wish to save changes we again go through the Items collections calling Save().

This allows us to locate changes that may be somewhere other than a WorkItem -- for instance, a ServiceAgent that's caching dirty data or some such.

Our first thoughts on this were with workItem.Terminating(), but we found that the Shell was already closed at this point, so it made canceling problematical.