Finally found the solution for this.
Limitations of other solutions:
ProMenubuttonPreactionSet() and ProMenubuttonPostactionSet() work for
Menu-Manager (mode-specific) menus only.
PRO_WINDOW_CHANGE_POST will be useful if there are multiple windows and
one of them is closed.
Correct Solution:
I am using ProCmdBracketFuncAdd to catch the command.
For this, we must know the command name which we can obtain from Trail
file.
For "File->Close Window" the command name is "ProCmdWinClose".
/*--------------------------------------------------------------------*/
/* Find uiCmdCmdId of the command to be handled */
uiCmdCmdId close_window_cmd_id;
status = ProCmdCmdIdFind("ProCmdWinClose", &close_window_cmd_id);
/* Catch the command */
if (status == PRO_TK_NO_ERROR)
{
ProCmdBracketFuncAdd(close_window_cmd_id,
(uiCmdCmdBktFn) FileCLoseAction,
"FileCLoseAction",
(void**)NULL);
}
ProError FileCLoseAction(uiCmdCmdId command, uiCmdValue *p_new_value,
int entering_command, void **data)
{
/* entering_command = 1, before executing the command
entering_command = 0, after executing the command
return PRO_TK_NO_ERROR if you don't want the command to be
executed.
In this case Model will not be closed, if you return
PRO_TK_NO_ERROR.
*/
return PRO_TK_CONTINUE;
}
//--------------------------------------------------------------------
Please let me know if this solution doesn't work for any of you.
I would like to deal with the scenario in which this solution fails.
Regards,
Vinay