当前位置: 代码迷 >> 编程 >> ocx手动平添事件
  详细解决方案

ocx手动平添事件

热度:5072   发布时间:2013-02-26 00:00:00.0
ocx手动添加事件

假设创建的ocx工程名称为AgentRest,要添加的事件为OnPreviewCallRequest。

1.AgentRest.idl文件中添加 [id(1)] OnPreviewCallRequest(long lCtrlID, BSTR lpCalls);

	[ uuid(7BC09251-081A-4AAE-A757-18D603CE4800),	  helpstring("Event interface for AgentRest Control") ]	dispinterface _DAgentRestEvents	{		properties:			//  Event interface has no properties		methods:        [id(1)] OnPreviewCallRequest(long lCtrlID, BSTR lpCalls);        }

2.AgentRestCtrl.h和AgentRestCtrl.cpp

// Dispatch and event IDspublic:    enum {  dispidSendEmailAttach = 193L,  dispidReplyOnlineMessageByEmail = 192L,  dispidReplyEmail = 1L,//事件        eventidOnPreviewCallRequest= 1L, };public:       //事件开始 void OnPreviewCallRequest(long lCtrlID, LPCTSTR lpCalls);
// Event mapBEGIN_EVENT_MAP(CAgentRestCtrl, COleControl)        EVENT_CUSTOM_ID("OnPreviewCallRequest", eventidOnPreviewCallRequest, OnPreviewCallRequest, VTS_I4 VTS_BSTR)END_EVENT_MAP()void CAgentRestCtrl::OnPreviewCallRequest(long lCtrlID, LPCTSTR lpCalls){    m_pDispatch->WriteLog(ERROR_EVENT, LOGINFO_EVENT_ONPREVIEWCALLREQUEST, lCtrlID, lpCalls);    FireEvent(eventidOnPreviewCallRequest, EVENT_PARAM(VTS_I4 VTS_BSTR), lCtrlID, lpCalls);}



 


 

 

  相关解决方案