1
Answer

CONVERT C++ to VB.NET

Purnima Devu

Purnima Devu

16y
5k
1

I am converting an application in C++ to VB.NET.

The C++ application uses ATL CAxWindow class, how do I convert this to VB.NET? I mean what is the equivalent of CAxWindow in VB.NET. Or how can I access the ATL CAxWindow class in VB.NET??

Basically I need to create a window in VB.NET windows service to host a LeadTools Control (third party tools).

 This is the function I am trying to convert to VB.NET from C++

void CreateLEADControl(CAxWindow& oWin)

{

try

{

const char* LICENSE = "LEADTOOLS OCX Copyright (c) 1991-2001 LEAD Technologies, Inc.";

_bstr_t strLicense = LICENSE;

AtlAxWinInit();

// Create an empty host window

RECT rect = {0,0,100,100};

oWin.Create(NULL,rect,"",WS_OVERLAPPED);

HRESULT hr;

IClassFactory2Ptr pCF;

IPersistStreamInitPtr pPSI;

// Get the class factory object for LEAD Tools

hr = CoGetClassObject(LEAD::CLSID_LEAD,CLSCTX_ALL,NULL,IID_IClassFactory2,(void**)&pCF);

// Create the LEAD Main control using the license

hr = pCF->CreateInstanceLic(NULL,NULL,__uuidof(LEAD::_DLead),strLicense,(void**)&mpLEAD);

pCF.Release();

// Initialize the new object

hr = mpLEAD->QueryInterface(&pPSI);

hr = pPSI->InitNew();

pPSI.Release();

Create a host window interface pointer

_COM_SMARTPTR_TYPEDEF(IAxWinHostWindow,IID_IAxWinHostWindow);

IAxWinHostWindowPtr pHost;

// Attach the new object to the host window

hr = oWin.AttachControl(mpLEAD,(IUnknown**)&pHost);

pHost.Release();

}

Thanks in advance,

Purnima.

Answers (1)