Example: Configure an AlarmItemClick Event

This example shows how to create a custom button that enables a user to view the values of alarm properties.

  1. Open the Properties - Object dialog box (Alt+Enter).

  2. Select the Events tab.

  3. Configure an AlarmItemClick event as follows.

A

Event

Select ActiveX Event.

B

ActiveX Event

Select AlarmItemClick.

C

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

  1. Click OK.

  2. 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.

More information

OnAlarmItemClick