Show Contents / Index / Search

Create an Event Procedure

You can add event procedures to any of the Reflection objects that support Automation events. Most of these objects appear in the Visual Basic Editor project pane (for example, IbmScreen or ThisScreen). For information about specific Reflection objects, see VBA Help from the Help menu.

To create an event procedure

  1. From Reflection 2011, open the Visual Basic Editor by clicking Tools > Visual Basic.
  2. In the Project Explorer window, expand the session project and then expand the Reflection Objects folder.
  3. Double-click the object for which you want to create an event procedure.
  4. In the upper-left corner of the Code window, from the Object list box, select the object name.

    An event procedure is inserted into the Code window automatically.

  5. In the upper-right corner of the Code window, from the Procedures/Events list box, select the event procedure you want.

    An empty event procedure is inserted in the Code window.

  6. In the procedure you just created, enter the code you want executed when the event occurs.

    For example, the following code uses the BeforeSendControlKey event of the IbmScreen object to display a notification before sending a Control key:

    Private Function IbmScreen_BeforeSendControlKey()
    If MsgBox("Send Control key?", vbOKCancel) = vbYes Then

    IbmScreen_BeforeSendControlKey = True
    End If
    End Function

    Note: This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Attachmate provides this sample code "AS IS" with no warranties.

  7. Choose File > Save [session filename] to save the Automation event as part of the session document.