Skip to content

CONVERT C++ to VB.NET

Purnima Devu

Asked Apr 30, 2008, 6:29 AM EDT1 answer
Share
LinkedInX

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++

Java
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.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Mahesh Chand
    0
    A Form represents a window in VB.NET. Don't think it as a conversion, otherwise you will not get the right idea of windows forms. Think like its a new approach of building windows applications.
    0