Using the Process Analyst > Process Analyst for Developers > Cicode Programming Reference > Handling an Event

Handling an Event

The Process Analyst contains many events that are triggered when certain actions occur. See Events.

To handle an event you need to provide a handler for the event by prepending your Process Analyst's event class name with the event name you want to handle and an underscore.

The example below shows how to define a handler for the "MouseClick" event with an event class defined as "CPA_E".

[VBA]

Sub CPA_E_MouseClick(pen As Object, button As Integer)
End Sub

[Cicode]

FUNCTION CPA_E_MouseClick(OBJECT hPA, OBJECT hPen, INT button)
END

The following example uses the MouseClick event to cancel the box zoom operation when the right mouse button is clicked.

Note: When referring to an ActiveX object in VBA, you need to prepend it with the page name and an underscore. In the example below, the page name is called "test". The object name is "CPA" and the event class name is "CPA_E".

[VBA]

Sub CPA_MouseClick(pen As Object, button As Integer)
Dim bZoomMode As Boolean

If (button = 1) Then
bZoomMode = test_CPA.ZoomMode

If (bZoomMode = True) Then
test_CPA.ZoomMode = False
End If
End If
End Sub

[Cicode]

FUNCTION CPA_E_MouseClick(OBJECT hPA, OBJECT hPen, INT button)
INT bZoomMode = 0;
IF (button = 1) THEN
bZoomMode = _ObjectGetProperty(hPA, "ZoomMode")
IF (bZoomMode = -1) THEN
_ObjectSetProperty(hPA, "ZoomMode", 0)
END
END
END