简体   繁体   中英

Detect mobile device minimizing

Windows Mobile 6.5.3 Professional
.NET Framework 3.5
C# Visual Studio 2008
Windows 7 Professional SP1

When the app runs on an MC75A, a small icon with an X (or OK if the form's MinimizeBox property is set false) is present at the top right in the "title bar". I have been advised that the app must terminate when that icon is pressed. I would like to establish an event handler to trigger on the press event, perform wrapup, and terminate the app (Application.Exit).

I do not know how to detect the icon press. Further, are there any suggestions on the best method to achieve shutdown?

TIA

The (X) is a minimize. It should minimize, not exit the app. Follow expected platform behavior. Clicking (ok) will close the Form, returning control back to whomever showed the Form. If the caller was Application.Run(), then the app will terminate normally and this is the pattern you should be striving to achieve. Closing a sub-form or dialog is again not expected behavior.

If you really must close the app, then just add this to the Form code:

    protected override void OnClosed(EventArgs e)
    {
        base.OnClosed(e);
        Application.Exit();
    }

Again, I'd still disagree with this. As a general rule, if your app is manually calling Application.Exit() , you have a design problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM