Detecting a window-close on a mobile device
Date: 01/29/08
(C Sharp) Keywords: no keywords
I'm writing a simple application for a Windows Mobile 6 device, in C#. I need to completely exit the application when the user clicks the X in the upper-right corner (by default, the application is left running in memory, but the form is hidden). Unfortunately, I can't figure out how on earth to detect this event.
On non-mobile platforms, this is detectable with a Closed or Closing event. On this device, though, the Event Handlers for those events are never called.
Also, the Visible and Enabled properties are still both true and the WindowState is Normal, even after the window disappears, so I can't figure out how to even catch the state through polling.
The only thing I've been able to figure out is that if I set MinimizeBox = true, then the X becomes an OK, and clicking the OK generates a Closed event. However, Giving the main application of a dialog box is just poor style and misleading to the users.
Can someone please tell me how I can accomplish this?
Source: http://community.livejournal.com/csharp/91798.html