I tried to prevent user closing dgn file if a certain task hasn't been finished using C#.
Is there an event handler on file closing and some parameter can be set so that the closing action can be canceled?
Gang
In C (aka MDL):
Private int queueMonitor (Inputq_element *qeP /* <=> pointer to queue element */) { if ( qeP->hdr.cmdtype == CMDNUM ) { switch ( qeP->u.cmd.command ) { case CMD_EXIT: case CMD_NEWFILE: case CMD_CREATE_DRAWING: case CMD_DIALOG_OPENFILE: case CMD_EXCHANGEFILE: case CMD_CLOSE_DESIGN:
if ( cancelDrawingClose ) return INPUT_REJECT;
break; } } return INPUT_ACCEPT; }// establish hook mdlInput_setMonitorFunction ( MONITOR_ALL, queueMonitor );
break; } } return INPUT_ACCEPT; }
}
// establish hook
mdlInput_setMonitorFunction ( MONITOR_ALL, queueMonitor );
Cheers,
/Chris Z.
Chris,
Thanks for your coding using MDL. Can that be implemented in C#? Since our current Add-in is written in C#.
Hi Gang,
Unknown said:Can that be implemented in C#?
I don't think so, I see no wrapper for mdlInput_setMonitorFunction in MDL help file. In the past (I am not sure if in this forum or in BDN community) alternatives what to do if a wrapper is missing were discussed, but it's not an easy way and it requires deep knowledge from more areas.
You have to accept today C# API (which is not "true NET API" but VBA/COM) is limited and C/C++ is the only way to receive maximum functionality. What about to create small MDL app, which will be loaded and controled (using key-ins) by your add-in and which will block a file unloading process?
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Answer Verified By: Gang
Hi Jan,
I really appreciate your help on it. I think that should be the only solution to our case.
Best,