You have to handle the OnCancelClose event and respond accordingly depending on whether to cancel or allow the event to proceed. Take a look at the Events sample (use the OPENDCLDEMO command to run samples quickly). There are also many examples of this in the OpenDCL forum.