Movicon Help on Line - Rel. 11.7.1301
ActiveX controls can also be edited on event in function with the properties provided by the control itself. The same object's method and property browser can be activated from the object's "Script Explorer". Based on how the object has been created, the code can set the properties according to the normal VBA™ comp. programming procedures described in the section dedicated to the Movicon VBA programming. As previously mentioned, it is not often possible to change ActiveX object properties through the Properties Window, therefore the object must be configured by using Basic Script codes.
|
Note! The ActiveX is entered as 'ActiveXInterface'. Therefore the methods and properties are called by using this interface (ActiveXInterface.<propriety or method>). The ActiveX events are also available from within the 'ActiveXInterface' interface. |
For instance, let's presume that we have to access the "Day" property of an ActiveX "Calendar" from the object's script code we would then have to write:
Option Explicit
Public Sub ActiveXInterface_Click()
Debug.Print ActiveXInterface.Day
End Sub
ActiveX object event management
The purpose of an ActiveX object inserted in a Movicon screen is to create events in function with the methods predisposed in the object itself. The Movicon programmer can insert Basic Script codes (VBA™ comp.) to execute the application's management and control logic to verify the event desired, provided by the ActiveX control. Code editing is done through the "Script Explorer" window after the object has been selected:
By means of the "Script Explorer" window you can select the event (or procedure) from those provided by the object. In order to do this you must first select the "ActiveXInterface" item from the list box called "Object": and then select the desired event from the list box call "Proc.". The code can be then entered and will be executed in runtime when the ActiveX generated the event.
|
The events provided are determined by how the object has been predisposed by those who created it. For further information on the operative modalities of the Basic Script codes, please consult the appropriate section dedicated to programming Movicon Basic Scripts. |
In response to the events you can also change the object according to the properties and methods provided by the object's creator.
ActiveX object properties and methods, if available, can be viewed by using the function browser. The browser is activated by using the Browse command found in the "Script Explorer's" tool bar.
How to reference an Active from a screen's symbol
It is often found necessary to give commands to the ActiveX object from objects contained on screen, such as buttons. In order to do this you need to create an object from the button's code to refer to the ActiveX. It will then be possible to use the methods and properties of that ActiveX through this object. In order to do this you will need to use some of the specific Basic Script functions. The example below shows you the necessary steps to take:
Example: Let's suppose that a Calendar ActiveX type has been inserted on screen in which a button is to be used for displaying the days selected in the Calendar. The basic code for this button would be:
Option Explicit
Public Sub Click()
Dim objContainer As Object
Dim objCalendar As Object
Set objContainer = GetSynopticObject.GetSubObject("Calendar1")
Set objCalendar = objContainer.GetActiveXObject
' properties depend on the object type
MsgBox "Selected Day = " & CStr(objCalendar.Day), vbInformation, GetProjectTitle
Set objContainer =Nothing
Set objCalendar =Nothing
End Sub
The "objCalendar" object is the Calendar object, therefore provides all the methods and properties belonging to the ActiveX.