About Events and Visual Basic Code

This section assumes that you have at least some background with the Visual Basic programming language. If you need to learn Visual Basic, please consult a book or other external resource on the subject.

The Events section on the Properties dialog box contains a list of event handler functions that your template or form object supports. An event handler function is called whenever the event implied by the name of the function occurs for the given object. When that function gets called, any Visual Basic code inside that function gets executed.

Available Event Handler Functions

EventClick
Called when the mouse is clicked on the object.

EventDblClick
Called when the mouse is double-clicked on the object.

EventDragDrop
Called when a "draggable" item is dropped onto the object.

EventDragEnter
Called when a draggable item is initially dragged onto the object.

EventDragOver
Called when a draggable item is dragged over the object.

EventInitialize
Called when the form first enters into run mode before any other handlers are called on the object.

EventMouseDown
Called when a mouse button is clicked down while over the object. If you press the Shift key, parameters passed to the function indicate which button is pressed as well as the pointer's coordinates at the moment you clicked the mouse button.

EventMouseMove
Called when the mouse pointer passes over the object. If you press the Shift key, parameters passed to the function indicate which button is pressed as well as the pointer's coordinates when you move the pointer over the object.

EventMouseUp
Called when you release the mouse button over the object. If you press the Shift key, parameters passed to the function indicate which button is pressed as well as the pointer's coordinates at the moment you release the mouse button.

EventPumpData
This is a widely used handler function in the Form Editor. EventPumpData is called whenever BASIC variables that may affect the object change value. Your code can also force EventPumpData to be called on individual objects (or on all objects in a report) when you wish an object to update itself. Basically, any code that an object needs to reinitialize itself based on variable values or the state of other objects should occur in EventPumpData.

EventTerminate
Called when the report is being closed or when you toggle from Run mode to Edit mode in the Form Editor.

This handler function is only available for the Section editing environments.

EventReportData
This is another most widely used handler function in the Report and Label Template editors. It gets called whenever report data gets plugged into the current template.

Its primary function is to let you create your own ActiveX controls that get placed into a label. For example, PC-DMIS's best fit and feature analysis controls use this event to send data to the ActiveX control from the command. To see this, open the label named best_fit_analysis.lbl, click on the ActiveX control inside the label, and then look at the BASIC code inside its event handler. A single line passes data from the command into the control.

With data passed to your own ActiveX control, you can then use automation commands to extract and manipulate the data.

For details on PC-DMIS Basic, see the "PC-DMIS Basic" topic in the PC-DMIS Basic documentation.

For details on PC-DMIS Automation Object Library, see the "PC-DMIS Object Library" topic in the PC-DMIS Automation Objects documentation.

This event gets called once for each command when applying the report template or during measurement routine execution.

Adding Code to Event Handlers

In order to add BASIC language code to any of the event handlers:

  1. Click on the function’s entry from the list of event handlers. A Mini Visual BASIC language editor opens, with the opening and closing statements of the subroutine already filled in.

  2. Type additional BASIC language statements code into the editor.

  3. Click OK.

  4. Test your code.

Since you don't interact with clickable buttons, lists, fields, or other interactive elements when you use a report, the only event handler function available is the EventReportData function.

More:

Event Example 1: Calling Code on an EventClick Event

Event Example 2: Modify Object Properties on Triggered Event

Access Object Methods