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 SPC Control Class and then click OK.

Toolbox Items

4) Now, you can create FabulaTech SPC 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. spcControl and click Finish.

Adding Member Wizard

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

BOOL status;
status = spcControl.IsEnabled();

Using ActiveX in Win32 Console Application Projects

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

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

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

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

CoInitialize(NULL);
try
{
	BOOL status;
	FTSPC::IFTSPCControlPtr spcControl(TEXT("FTSPC.FTSPCControl"));
	status = spcControl->IsEnabled();
}
catch(_com_error error)
{
	// ToDo: Handle error
}