![]() ![]() ![]() |
Here comes a few steps that should the taken to use SXY as a COM application inside Visual Basic.
Before creating and manipulating graphs and curves, you must start the SXY/COM application:
Public sxycom_obj as Object sxycom_obj = CreateObject(“SXYCOM.Application”) |
Then, you can construct the objects.
Public graph as Object Public curve as Object Set graph = sxycom_obj.createSimpleGraph(LINEAR_SIMPLE_GRAPH, 300, 300) Set curve = sxycom_obj.createArrayCurve() |
And manipulate them.
graph.setTitle “Test” curve.setTitle "Sample Curve" graph.attachCurveById curve.getId() graph.redrawGraph |
To get information about the the objects and methods available in SXY/COM, you can use the Visual Basic Object browser. To do so, you need to add a reference to SXY/COM type library, as follows:
Now the SXY/COM types will be accessible in the Object Browser. There you can see the interfaces, their methods and some help about each method. It also allows the use of enumerations members like LINEAR_SIMPLE_GRAPH.
The default operation of SXY/COM does not generate events. Nevertheless, the default interface of the graphics can be extended with the use of themes. A theme may add menus and buttons to the default interface. The events generated by these interface elements can be sent to the client application through a Visual Basic function. Do do so, SXY/COM must be started in a different fashion.
Public WithEvents sxycom_obj_evt As sxycom.Application Public sxycom_obj As Object Set sxycom_obj_evt = New sxycom.Application Set sxycom_obj = sxycom_obj_evt |
To initialize SXY/COM this way, you must add a reference to its type library inside VB (see the former section). This initialization ensures that Visual Basic will received events from SXY/COM.
In fact, it generates only one event: genericEvent. It can be captured implementing the following function:
Sub sxycom_obj_evt_genericEvent(ByVal graph As Object, ByVal event_name As String) ‘ Put your code here End Sub |
Notice that the prefix of the function is the name of the variable holding the reference to the SXY/COM object created with New. This variable must be used only for this. You should not call SXY/COM methods on it. Use otherwise the one of type Object.