views:

1155

answers:

2

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.

+5  A: 

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.

Martin Plante
A: 

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).

Shane Powell