Visual C++ 4.0 Syntax

In Version 4.0 of Visual C++, the MicroSoft Foundation Class (MFC) library provides an ActiveX interface. This topic describes how to use the interface with the LEADTOOLS ActiveX.

To add a LEAD control to your application, refer to the example in Loading and Displaying an Image.

Alternatively, to create an instance of the LEAD control at run time, use the Create function, which has the following prototype:

BOOL Create( LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT&rect, CWnd* pParentWnd, UINT nID,
CFile* pPersist = NULL, BOOL bStorage = FALSE,
BSTR bstrLicKey = NULL);

Provide parameters as follows:

lpszWindowName

Use "", because the control window does not need a name.

dwStyle

Use 0 for the default style.

&rect

Use the CRect function. For example: CRect(0,0,50,50).

pParentWnd

Use this to refer to the current window.

nID

Use 0 for the default ID.

pPersist

Use NULL.

bStorage

Use FALSE.

bstrLicKey

Use the LEADTOOLS license string, which is always the first line in the LTOCX.LIC file. For example: "LEADTOOLS OCX Copyright (c) 2010 LEAD Technologies, Inc." If you do not specify this string correctly, the ActiveX will not work when you distribute your application.

For example, the following code comes from the EXAMPLES\OCX\MFC40\DEMO\MAINDEMO.CPP file:

static const WCHAR BASED_CODE _szLicString[] =
L"LEADTOOLS OCX Copyright (c) 2001 LEAD Technologies, Inc.";
o
o
o
m_pLead = new CLead;
// pass the license string to the CLead::Create function.
// The CLead::Create expects a BSTR parameter and SysAllocString converts the
// WCHAR[] to a BSTR
BSTR lpLic = SysAllocString(_szLicString);
m_pLead->Create("", 0,CRect(0,0,50,50),this,0,NULL,FALSE,lpLic);
m_pLead->ShowWindow(SW_HIDE);
SysFreeString(lpLic);

When getting or setting a property value, you must use a function that is created by adding a prefix to the property name.

To set a property value, the syntax is as follows:

m_controlname.Setpropertyname(value);

For example:

m_Lead1.SetRubberBandVisible(FALSE);

To get a property value, the syntax is as follows:

value = m_controlname.Getpropertyname();

For example:

HeightFactor = m_Lead1.GetBitmapHeight();

To set a property array value, the syntax is as follows:

m_controlname.Setpropertyname(index, value);

For example:

m_Lead1.SetRemapTable(MyIndex, (255 * Offset) / CurrentRange);

To get a property array value, the syntax is as follows:

value = m_controlname.Getpropertyname(index);

For example:

m_Lead1.SetBitmap(m_Lead1.GetColorPlanes(3)); // Copy the K plane