This example shows how to create a custom button that enables a user to view the values of alarm properties.
Open the Properties - Object dialog box (Alt+Enter).
Select the Events tab.
Configure an AlarmItemClick event as follows.
Event |
Select ActiveX Event.
ActiveX Event |
Select AlarmItemClick.
Action |
Create a new script.
For this example a user will display a message box when an alarm is selected and either of the following occurs.
Right mouse button is clicked.
Note: The Allow runtime popup menu checkbox on the CIMPLICITY AMV Control Properties dialog box Display tab is clear .
Enter is pressed on the keyboard.
The script is as follows.
Private cimOleObj As AMVOCXLib.IAmvOcx
Sub OnAlarmItemClick(AlarmInfo As AMVOCXLib.AmvOcxAlarmItemInfo, ClickSource As Long)
Dim sourceStr As String
Select Case ClickSource
Case AMV_LeftMouseButton
sourceStr = "AMV_LeftMouseButton"
Case AMV_RightMouseButton
sourceStr = "AMV_RightMouseButton"
Case AMV_EnterKey
sourceStr = "AMV_EnterKey"
End Select
If ClickSource=AMV_EnterKey Or ClickSource=AMV_RightMouseButton Then
Dim DataString As String
DateString = Format(AlarmInfo.GenerationTime, "mmm dd hh:nn:ss AM/PM")
MsgBox "AlarmIdentifier = " & AlarmInfo.AlarmIdentifier & ebCRLF & _
"ResourceIdentifier = " & AlarmInfo.ResourceIdentifier & ebCRLF & _
"ReferenceIdentifier = " & AlarmInfo.ReferenceIdentifier & ebCRLF & _
"AlarmGenTime = " & DateString & ebCRLF & _
"AlarmScreen = " & AlarmInfo.AlarmScreen & ebCRLF & _
"AlarmMessage = " & AlarmInfo.AlarmMessage & ebCRLF & _
"TranslatedAlarmMessage = " & AlarmInfo.TranslatedAlarmMessage & ebCRLF & _
"Click Source = " & sourceStr
End If
End Sub
Click
.Test the Properties script.
Result: When a user selects an alarm and either right-clicks or presses Enter on the keyboard, a Message box displays. Values for the properties specified in the script are listed.
A |
AMV_RightMouseButton is the Click Source when the alarm is right-clicked. |
B |
AMV_EnterKey is the Click Source when the Enter key is pressed. |
OnAlarmItemClick |