Microsoft Visual Studio 2005. Visual C++

Using ActiveX in MFC Application Projects

1) On the Tools menu, click Choose Toolbox Items...

Tools menu

2) In the Choose Toolbox Items dialog box, click the COM Components tab.

3) Select FabulaTech VSPC Control Class and then click OK.

Toolbox Items

4) Now, you can create FabulaTech VSPC Control Class objects. Just drag and drop our control on your form.

Adding Control to Form

5) Add variable of the control to the class of your dialog. To do it, right-click on the control and choose Add Variable...

Adding New Variable

6) Specify name of variable, e.g. vspcControl and click Finish.

Adding Member Wizard

7) Now, we can reference the control using specified name. For example:

BOOL status;
status = vspcControl.IsEnabled();

Using ActiveX in Win32 Console Application Projects

Use #import preprocessor directive to add ActiveX component to your application.

#include "stdafx.h"
#import "ftvspcax.dll"

Compiler will automatically generate all necessary code for working with this component and put it into the namespace with name FabulaTech VSPC Control Class.

You can declare object and access methods and properties in the following way:

CoInitialize(NULL);
try
{
	BOOL status;
	FTVSPC::IFTVSPCControlPtr vspcControl(TEXT("FTVSPC.FTVSPCControl"));
	status = vspcControl->IsEnabled();
}
catch(_com_error error)
{
	// ToDo: Handle error
}