How to insert an ActiveX element in zenon?

Previous chapterNext chapter Show allShow all    Hide allHide all

An ActiveX element is drawn into the picture like any other dynamic element; a dialog opens, where you musz select an ActiveX element.

After you have selected the element from the list, you can links variables to it. For this click the button Variable and select a variable resp. create a new one.

In the next step we give the ActiveX element an object name, so that we can access it in VBA.

In our example we give it the object name Slide6_DW18, because it is an AcziveX element Slider linked to the variable Doubleword18.

Now the Slider element has to be activated and edited in the VBA Editor.

For this we craete a new macro.

The macro Init_Slider passes the element to be initialized to a sub program in the control system object thisProject, whereby the allocation to the current project is defined.

Public SubInit_Slider(obElem AsElement)
thisProject . Init _ Slider obElem
End Sub

Just like in the macro Init_Slider also Draw_SliderValue passes the element to the control system object thisProject.

Public Sub Draw_SliderValue (obElem As Element, ByVal hdc As OLE _ HANDLE )
thisProject.Draw_Slider obElem
obElem.Draw hdc
End Sub

The code below is added in the control system object this Project.

Public Declarations
Public WithEvents obSlider As Slider
Public obSliderPV As Variable
Public Sub Init_Slider (obElem As Element)
Set obSlider = obElem.ActiveX

'ActiveX exists
If obSlider Is Nothing Then
Exit Sub
End If
Set obSliderPV = obElem . ItemVariable(0)
'variable exists
If obSliderPV Is Nothing Then
Exit Sub
End If
obSlider.Max = obSliderPV.RangeMax
obSlider.Min = obSliderPV.RangeMin
obSlider.TickFrequency = 1000
obSlider.LargeChange = 25
obSlider.SmallChange = 1
obSlider.Value = obSliderPV.Value

End Sub

Public Sub Draw _ Slider ( obElem As Element )
Dim vVar As Variant
Dim obDynPic As DynPicture

Set obSliderPV = obElem.ItemVariable ( 0 )
Set obDynPic = thisProject.DynPictures. Item (BILD_1)
'variable exists
If obSliderPV Is Nothing Then
Exit Sub
End If