Assume that the created ocx project is named AgentRest and the event to be added is OnPreviewCallRequest. 1. agentRest. add [id (1)] OnPreviewCallRequest (long lCtrlID, BSTR lpcils) to the idl file; [cpp] [uuid (UID), helpstring ("Event interface for AgentRest Control")] dispinterface _ dagentresteven ts {properties: // Event interface has no properties methods: [id (1)] OnPreviewCallRequest (long lCtrlID, BSTR lpcils);} 2. agentRestCtrl. h and AgentRestCtrl. cpp [cpp] // Dispatch and event IDs public: enum {dispidSendEmailAttach = 193L, region = 192L, dispidReplyEmail = 1L, // event eventidOnPreviewCallRequest = 1L,}; public: // The Event starts void OnPreviewCallRequest (long lCtrlID, LPCTSTR maid); [cpp] // Event map encode (CAgentRestCtrl, COleControl) EVENT_CUSTOM_ID ("OnPreviewCallRequest", callback, OnPreviewCallRequest, callback) callback () void callback: OnPreviewCallRequest (long lCtrlID, LPCTSTR lpcils) {m_pDispatch-> WriteLog (ERROR_EVENT, events, lCtrlID, lpcils); FireEvent (events, EVENT_PARAM (callback ), lCtrlID, maid );}