Respond to an event
virtual void Update( CXlBeforeCloseEventArgs* e ); |
A pointer to an event arguments object is sent to the Update method.
Derived classes should implement this function, which is the event handler for the XLL+ event model.
The code below defines a class derived from CXlWorkbookBeforeCloseEventStaticObserver, implements an Update method which is called when the event occurs, and instantiates an instance of the new class.
Note that this particular Update method uses CXlBeforeCloseEventArgs::SetCancel to cancel the event, and prevent the workbook from being closed.
// Define a class derived from CXlWorkbookBeforeCloseEventStaticObserver class CMyWorkbookCloseEventObserver : CXlWorkbookBeforeCloseEventStaticObserver { public: // This method will be called during the XlWorkbookBeforeClose event. virtual void Update(CXlBeforeCloseEventArgs* e) { CXllApp::XlMessageBox(_T("Closing ") + e->GetBookName(), XlMessageBoxTypeInformation); e->SetCancel(true); } }; // Create an instance of the class CMyWorkbookCloseEventObserver myWorkbookCloseObserver;
Header: xlpevents.h
CXlWorkbookBeforeCloseEventStaticObserver Class | CXlWorkbookBeforeCloseEventStaticObserver Methods