confirm exit of Smart Client

I have code that confirms the user wants to exit the Smart Client when they click a Logout button. Is there a way to create a user confirmation when they simply click the “X” (in Windows) to close the main window of the application? Or maybe there is a way to disable the “X”?

Just attach the function below to the ‘onClose’ event handler.
You’ll find this event in the properties off the (main) solution.

/**
 * Callback method for when solution is closed, force boolean argument tells if this is a force (not stoppable) close or not.
 *
 * @param {Boolean} force if false then solution close can be stopped by returning false
 *
 * @returns {Boolean}
 */
function onSolutionClose(force) {
	var _sAnswer = 'OK';
	
	if(!force) {
		_sAnswer = plugins.dialogs.showQuestionDialog('Exit application','Are you sure you want to exit the application?', 'Cancel', 'OK');
	}
	
	return (_sAnswer == 'OK')
}

Perfect! Works great. Thank you!!