Importing the control into visual c – Echelon LNS User Manual

Page 61

Advertising
background image

LNS Programmer's Guide

47

Once the tool is part of the Visual Basic tool palette, you can add the LNS Object Server

to an application by selecting the tool and dragging it onto one of the application’s forms.
To do so, follow these steps:

1. Select the LNS Object Server icon on the Visual Basic tool palette.

2. Drag the Object Server control onto one of your application’s forms. By

default, the name of the control will be [formName].LcaObjectServer1,
where [formName] is the name of the form where you placed the control.

3. Optionally, change the name of the Object Server control by setting the Name

property for the control.

Importing the Control into Visual C++

To import the LNS Object Server control into Visual C++ and Visual C++ .NET, make

sure that the LNS Application Developer’s Kit is installed on your development PC, and

then add the following statement to a global header file for your project, such as
StdAfx.h:

“#import "lcaobjsv.ocx" named_guids rename_namespace("lca")”

This statement will direct the preprocessor to locate the LNS type library, and create

header files containing wrappers that expose the available interfaces. Once the wrappers
are created, the #import statement will also serve as an include statement for the

wrapper header files. For more information on this, see Appendix B, LNS, MFC and

ATL.

For Visual C++ .NET, adding the #import statement shown above is the only step you

need to take to import the LNS Object Server control. If you are using Visual C++ 6.0
and want to use the MFC Class Wizard for event handlers, perform these steps as well:

1. From

the

Project menu, select the Add to Project command. Then, select

the Components and Controls Item in the sub-menu. This activates the

Component and Controls Gallery.

2. Open

the

Registered ActiveX Controls folder.

3. Select

the

L

ON

W

ORKS

ObjectServer control icon, and click Insert.

4. A confirmation dialog appears with the name of the wrapper class to be

created for the Object Server.

5. Click

the

OK button to finish adding the control. The LNS Object Server

control now appears as a tool icon in the resource editor’s control toolbar.

6. Click

the

Close button to close the component gallery dialog.

Once the control is part of the resource editor’s toolbox, you can add the control to an

application by dragging the control from the toolbox onto a dialog resource, and then

using the MFC Class Wizard to create the member variable for the control and its LNS

Object class definitions. When creating a Visual C++ application, Echelon recommends
that you do not reduce the default Visual C++ stack size.

To create an instance of the Object Server control in a Visual C++ application, follow

these steps:

1. Select the LNS Object Server icon on the resource editor toolbox.

Advertising