Udostępnij za pośrednictwem


Implementing the Load-Complete and Entry-Point Events

TextInterpreter implements the IDebugLoadCompleteEvent2 interface on the CLoadCompleteEvent class and the IDebugEntryPointEvent2 interface on the CEntryPointEvent class. Note that both of these interfaces have no additional methods, so only the IUnknown methods need to be implemented (using the macros you set up earlier).

To implement the load complete and entry point events

  1. In Solution Explorer, right-click the TextInterpreter project and click Add Class.

  2. Add a Generic C++ Class with the Class name CLoadCompleteEvent and set its Base class to IDebugLoadCompleteEvent2. Set the .h file to EventBase.h and the .cpp file to EventBase.cpp. Make sure that Access is set to public and then click Finish. Answer Yes to the prompts that ask if you want to merge with the contents of the specified file.

  3. Add another Generic C++ Class with the Class name CEntryPointEvent and a Base class of IDebugEntryPointEvent2. Set the .h file to EventBase.h and the .cpp file to EventBase.cpp. Make sure that Access is set to public and then click Finish. Answer Yes to the prompts that ask if you want to merge with the contents of the specified file.

  4. Open the EventBase.h file, find the declaration for the new class CLoadCompleteEvent, and modify the class declaration to look like the following:

    class CLoadCompleteEvent :
        public IDebugLoadCompleteEvent2, 
        public CEventBase 
    { 
    
  5. After the declaration of the CLoadCompleteEvent destructor, add the following bold lines. This is the macro that declares the IUnknown interface methods.

        ~CLoadCompleteEvent(void);
    
        //////////////////////////////////////////////////////////// 
        // IUnknown methods 
        DECLARE_IUNKNOWN 
    
  6. In the EventBase.h file, find the declaration for the new class CEntryPointEvent and modify the class declaration to look like the following:

    class CEntryPointEvent :
        public IDebugEntryPointEvent2, 
        public CEventBase 
    { 
    
  7. After the declaration of the CEntryPointEvent destructor, add the following bold lines. This is the macro that defines the IUnknown interface methods.

        ~CEntryPointEvent(void);
    
        //////////////////////////////////////////////////////////// 
        // IUnknown methods 
        DECLARE_IUNKNOWN 
    
  8. Open the EventBase.cpp file and modify the constructor for CLoadCompleteEvent to look like this:

    CLoadCompleteEvent::CLoadCompleteEvent(void)
    : CEventBase(IID_IDebugLoadCompleteEvent2, EVENT_SYNC_STOP) 
    {
    }
    
  9. After the definition for the CLoadCompleteEvent destructor, add the following bold lines. This is the macro that defines the IUnknown interface methods.

    CLoadCompleteEvent::~CLoadCompleteEvent(void)
    {
    } 
    
    ////////////////////////////////////////////////////////////////////////////// 
    // IUnknown 
    IMPLEMENT_IUNKNOWN(CLoadCompleteEvent, IDebugLoadCompleteEvent2) 
    
  10. In the EventBase.cpp file, modify the constructor for CEntryPointEvent to look like this:

    CEntryPointEvent::CEntryPointEvent(void)
    : CEventBase(IID_IDebugEntryPointEvent2, EVENT_SYNC_STOP) 
    {
    }
    
  11. After the definition for the CEntryPointEvent destructor, add the following. This is the macro that defines the IUnknown interface methods.

    CEntryPointEvent::~CEntryPointEvent(void)
    {
    }
    
    ////////////////////////////////////////////////////////////////////////////// 
    // IUnknown 
    IMPLEMENT_IUNKNOWN(CEntryPointEvent, IDebugEntryPointEvent2) 
    
  12. Build the project to make sure there are no errors.

See Also

Tasks

Sending Load-Complete and Entry-Point Events