I am facing ERROR "C3702 atl is required for com events" in my source code but nothing help me to resolve this one.
Including these headers in stafx.h or .h file does not work:
#include <comdef.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
commenting and un commenting this line in stdafx.h or .h file does work: //using namespace ATL;
Adding below line in stdafx.h or .h file does not work: #define _ATL_ATTRIBUTES 1
Adding ATL support in MFC also does not work for me.
CoInitialize(NULL) and CoUninitialize() are also written in the main but not solved
Commenting this line change the error nature but no solution: //[event_receiver(com)] This line cause Compiler Error C3731 (incompatible event 'function1' and handler 'function2'; event source and event handler must be the same type)
.H File
#define _ATL_ATTRIBUTES 1
#pragma once
#include "stdafx.h"
[event_receiver(com)]
class CMainDlg
{
public:
CMainDlg() {};
~CMainDlg() {};
public:
bool OnCallStart();
HRESULT AbtoPhone_OnInitialized(BSTR Msg);
void HookPhoneEvents(IAbtoPhone* pSource);
void UnHookPhoneEvents(IAbtoPhone* pSource);
};//CMainDlg
CPP File
#include "stdafx.h"
#include "MainDlg.h"
bool CMainDlg::OnCallStart()
{
HRESULT hr = m_AbtoPhone.CreateInstance(__uuidof(CAbtoPhone));
if (FAILED(hr))
{
AfxMessageBox(_T("Can't load CAbtoPhone component.\nCheck is registered 'SIPVoIPSDK.dll'"));
}
HookPhoneEvents(m_AbtoPhone);
return true;
}
void CMainDlg::HookPhoneEvents(IAbtoPhone* pSource)
{
__hook(&_IAbtoPhoneEvents::OnInitialized, pSource, &CMainDlg::AbtoPhone_OnInitialized);
}
void CMainDlg::UnHookPhoneEvents(IAbtoPhone* pSource)
{
__unhook(pSource);
}
HRESULT CMainDlg::AbtoPhone_OnInitialized(BSTR Msg)
{
return S_OK;
}
I am using Microsoft Visual Studio 2017 Community edition.