Respond to an event
virtual void Update( CXlWorkbookEventArgs* 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 CXlNewWorkbookEventStaticObserver, implements an Update method which is called when the event occurs, and instantiates an instance of the new class.
// Define a class derived from CXlNewWorkbookEventStaticObserver class CMyNewWorkbookEventObserver : CXlNewWorkbookEventStaticObserver { public: // This method will be called during the XlNewWorkbook event. virtual void Update(CXlWorkbookEventArgs* e) { CXllApp::XlMessageBox(_T("Creating ") + e->GetBookName(), XlMessageBoxTypeInformation); } }; // Create an instance of the class CMyNewWorkbookEventObserver myNewWorkbookObserver;
Header: xlpevents.h
CXlNewWorkbookEventStaticObserver Class | CXlNewWorkbookEventStaticObserver Methods