Dan
Dan

Reputation: 29365

Making the window [X] button close instead of minimise on Windows Moblie

The [x] button in the top bar of a window that normally closes the window in standard Windows, appears to do a minimise instead on Windows Compact.

How do it make it close instead? I need to also be able to raise an event when this happens as I want to preform some logic on window close.

Upvotes: 5

Views: 2235

Answers (2)

Shane Powell
Shane Powell

Reputation: 14148

I'm not sure how this relates to the .NET forum support but you need to use the Native API SHDoneButton.

By default it's set to "SHDB_HIDE" which then shows the "Windows Mobile" "X" button (or any application that overrides X button like LGE's 'X' button application, or the HTC one).

If you set it to "SHDB_SHOW" it will show a "ok" button which sends a IDOK to the window if pressed. If you set it to "SHDB_SHOWCANCEL" it will show a "x" button which sends a IDCANCEL to the window if pressed. SHDB_SHOWCANCEL is not documented by MSDN but it's in the header file (aygshell.h).

Upvotes: 0

Martin Plante
Martin Plante

Reputation: 4703

Set the Form.MinimizeBox property to false. This will change the [X] to [ok], and close your form instead of minimizing it when clicked.

Edit: The event you want is either Closing or Closed.

Upvotes: 9

Related Questions