I have managed to make it work.
For those who face the same issue, here is what I have done:
Wizard generates code similar to below:
Header file:
#pragma once
#include "afxwin.h"
class YourClassName : public CWnd
{
protected:
DECLARE_DYNCREATE(YourClassName )
public:
CLSID const& GetClsid()
{
static CLSID const clsid
= {0x3a614790,0xdc9e,0x4e5e,{0xb1,0xa3,0x91,0x97,0x84,0x57,0xc2,0x0a}};
return clsid;
}
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = nullptr)
{
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
}
BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
UINT nID, CFile* pPersist = nullptr, BOOL bStorage = FALSE,
BSTR bstrLicKey = nullptr)
{
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
pPersist, bStorage, bstrLicKey);
}
public:
public:
};
In the
//Operations
part, define your missing functions, like below:
public:
void Read();
void Write();
CPP file:
Implement missing function like in the below example, and call
InvokeHelper
.
The hexadecimal argument is the ordinal of your missing function, you can find it in the ActiveX Control's IDL file.
#include "pch.h"
#include "YourClassName.h"
IMPLEMENT_DYNCREATE(YourClassName, CWnd)
void COCX::Read()
{
InvokeHelper(0x02, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
void COCX::Write()
{
InvokeHelper(0x01, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
Hope this helps someone, thank you everyone for trying to help.