If you don't want the default windows mobile behavior you will need to call the function SHDoneButton.
It takes three possible arguments:
SHDB_HIDE- which is the default and WM most likely displays the 'X' button and will minimize your app when it's pressed. Also note on some devices the 'X' button will send aWM_QUITto your application.SHDB_SHOW- will show a 'ok' button and will send a IDOKWM_COMMANDto your window when pressed.SHDB_SHOWCANCEL- will show a 'x' button and will send a IDCANCELWM_COMMANDto your window when pressed.