Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Registering and Handling .NET and ActiveX Events

LabVIEW 8.2 Help
August 2006

NI Part Number:
371361B-01

»View Product Info
Download Help (Windows Only)

When handling a .NET or ActiveX event, you must register for the event (see steps 1 through 5) and then create a callback VI to handle that event (see steps 6 and 7). Complete the following steps to register and handle .NET and ActiveX events in LabVIEW.

  1. Create a new control in a .NET container or an ActiveX container. You also can use the Constructor Node to create a .NET object or use the Automation Refnum to call an ActiveX object from LabVIEW.
  2. Place the Register Event Callback function on the block diagram.

  3. Wire the reference or object to the Event input of the Register Event Callback function.
  4. Click the down arrow next to the Event input on the Register Event Callback function and select an event from the shortcut menu.
  5. (Optional) Wire the data that you want to pass to the callback VI to the User Parameter input. You can wire any LabVIEW data type, including a cluster, to this parameter.
  6. Right-click the VI Ref input and select Create Callback VI from the shortcut menu. LabVIEW creates a VI based on the event you select and the data you wire to the User Parameter. LabVIEW wires the callback VI to the VI Ref input.
Note  You can use an existing VI as a callback VI as long as the connector pane of the VI you intend to use matches the connector pane of the event data. The callback VI must be reentrant, and the reference to the callback VI must be strictly typed.
  1. Open the callback VI and edit the block diagram to handle the event. The callback VI contains the following elements:
    • Event Common Data contains the following elements:
      • Event Source is a numeric control that specifies the source of the event, such as LabVIEW, .NET, or ActiveX. A value of 1 indicates an ActiveX event. A value of 2 indicates a .NET event.
      • Event Type specifies which event occurred. This is an enumerated type for user interface events and a 32-bit unsigned integer type for .NET, ActiveX, and other event sources. For .NET and ActiveX events, the event type represents the method code, or ID, for the event registered.
      • Time Stamp is the time stamp in milliseconds that specifies when the event was generated.
    • Control Ref is a reference to the .NET or ActiveX object or the Automation Refnum on which the event occurred.
    • Event Data is a cluster of the parameters specific to the event the callback VI handles. LabVIEW determines the appropriate Event Data when you select an event from the Register Event Callback function. If an event does not have any data associated with it, LabVIEW does not create this control in the callback VI.
    • Event Data Out is a cluster of the modifiable parameters specific to the event the callback VI handles. This element is available only if the event has output parameters.
    • (Optional) User Parameter is data that you want to pass to the callback VI when the .NET or ActiveX object generates the event.

Resources

WAS THIS ARTICLE HELPFUL?

Not Helpful