Hello All;
I am working on C++/MFC project where I need to consume an active x control, so I create a control like
CZKEM1 m_zktecoCtrl;
but when I try to invoke it Like
bool bConnect = false;
bConnect = m_zktecoCtrl.Connect_Net(L"192.168.1.201", 4370);
a message popup say
"Invalid number of parameters"
What I have tried:
code in my Control h file
#pragma once
#include "afxwin.h"
class CZKEM1 : public CWnd
{
protected:
DECLARE_DYNCREATE(CZKEM1)
public:
CLSID const& GetClsid()
{
static CLSID const clsid
= { 0x00853a19,0xbd51,0x419b,{0x92,0x69,0x2d,0xab,0xe5,0x7e,0xb6,0x1f} };
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:
BOOL Connect_Net(BSTR IPAdd, long Portl)
{
BOOL result;
static BYTE parms[] = VTS_BSTR VTS_I4;
InvokeHelper(0x15, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms, IPAdd, Portl);
return result;
}
};
My code in Dialog h file
public:
CZKEM1 m_zktecoCtrl;
}
My code in Dialog cpp file
void CzkTestDlg::OnBnClickedConnectButton()
{
bool bConnect = false;
bConnect = m_zktecoCtrl.Connect_Net(L"192.168.1.201", 4370);
if (bConnect)
{
MessageBox("Connection Succeeded ");
}
else MessageBox("Connection Failed");
}