Register or unregister your add-on to be notified of application and project events.
GSErrCode ACAPI_Notify_CatchProjectEvent ( GSFlags eventTypes, APIProjectEventHandlerProc* handlerProc );
Parameters
- eventTypes
- [in] A combination of different API_NotifyEventID values, specifying the types of project events you are interested in.
- handlerProc
- [in] The callback procedure to call when notifications are sent out on different project events. Specifying
nullptr
here means you don’t need the notifications any more.
Return Values
NoError
- The requested operation finished successfully.
For other common API errors see the API Errors document.
Remarks
This function enables the API tool add-on catch events happening to the project. Each time when such an event occurs the server application calls the supplied handlerProc
of your those add-ons which have been registered for this event previously.
If you do not need to catch the project events any longer, please remember to unregister by calling ACAPI_Notify_CatchProjectEvent
for the required element type with nullptr
in the handlerProc
parameter.
Example
// ----------------------------------------------------------------------------- // Project event handler function // ----------------------------------------------------------------------------- static GSErrCode __ACENV_CALL NotificationHandler (API_NotifyEventID notifID, Int32 param) { char msgStr[256]; switch (notifID) { case APINotify_New: CHCopyC ("APINotify_New", msgStr); break; case APINotify_NewAndReset: CHCopyC ("APINotify_NewAndReset", msgStr); break; case APINotify_Open: CHCopyC ("APINotify_Open", msgStr); break; case APINotify_PreSave: CHCopyC ("APINotify_PreSave", msgStr); break; case APINotify_Save: CHCopyC ("APINotify_Save", msgStr); break; case APINotify_Close: CHCopyC ("APINotify_Close", msgStr); break; case APINotify_Quit: CHCopyC ("APINotify_Quit", msgStr); break; case APINotify_SendChanges: CHCopyC ("APINotify_SendChanges", msgStr); break; case APINotify_ReceiveChanges: CHCopyC ("APINotify_ReceiveChanges", msgStr); break; case APINotify_ChangeProjectDB: CHCopyC ("APINotify_ChangeProjectDB", msgStr); break; case APINotify_ChangeWindow: CHCopyC ("APINotify_ChangeWindow", msgStr); break; case APINotify_ChangeFloor: CHCopyC ("APINotify_ChangeFloor", msgStr); break; case APINotify_ChangeLibrary: CHCopyC ("APINotify_ChangeLibrary", msgStr); break; } ACAPI_WriteReport (msgStr, false); return NoError; } // NotificationHandler // ----------------------------------------------------------------------------- // Called after the Add-On has been loaded into memory // ----------------------------------------------------------------------------- GSErrCode __ACENV_CALL Initialize (void) { // catch changes in project events GSErrCode err = ACAPI_Notify_CatchProjectEvent (API_AllProjectNotificationMask, NotificationHandler); return err; } // Initialize
Requirements
- Version: API 4.1 or later
- Header: ACAPinc.h
See Also
API_NotifyEventID, APIProjectEventHandlerProc,
Notification Manager, API Functions