Purpose

This example shows how you can use custom UI messages to communicate between the client sequence file and the user interface.

  • Sending data from the sequence to the UI—The Sequence posts UI messages containing a status string. The UI message handler reads the string and updates a UI control with the data.
  • Sending data from the UI to the sequence—Before executing, the sequence posts a message requesting the state of the "show dialogs" UI setting. The UI message handler sets the Locals.ShowDialogs sequence property using the TestStand API, based on the value specified in the UI.
Note In order for the UI messages posted in this sequence to be handled, you must execute the sequence in the "Basic User Interface with UI Message Handler" Interface, located in the language specific subfolders of this sequence file. While the sequence will run successfully in the Sequence Editor or other user interfaces, the user messages posted will have no effect.

Example File Location

<TestStand Public>\Examples\Modifying User Interfaces\Handling UI Messages\LabVIEW\Using Custom UI Messages.lvproj

Highlighted Features

  • User Interface Messages
  • TestStand User Interface controls

Major API

Thread.PostUIMessageEx

Prerequisites

You must have the LabVIEW Development System installed to view this example.

How to Use This Example

Complete the following steps to run the example:

  1. In Using Custom UI Messages.lvproj, open Basic User Interface with UI Message Handler.vi.
  2. Click the Run button on the VI to start the user interface. The UI Message example sequence is opened by the UI automatically.
  3. Run the sequence. Notice that the sequence status is updated as each UI message is posted with ID 10100.
  4. After the execution completes, uncheck the Show Sequence Dialogs option on the user interface. Run the sequence again and notice that the message dialogs no longer appear. The dialogs no longer appear because the Sequence File posts UI message 10200. The handler for this message sets the FileGlobals.ShowDialogs property to the value of the Show Sequence Dialogs setting in the setup step group.
  5. You can optionally execute this sequence file in other user interfaces that do not handle the specified user messages. The sequence will run successfully, but the user messages posted will have no effect.

Complete the following steps to review the UI message handling code in the UI:

  1. In Using Custom UI Messages.lvproj, open Basic User Interface with UI Message Handler.vi.
  2. In the Register Event Callbacks case, notice that UserMessage Event Callback.vi is registered to the UserMessage event.
  3. Open the UserMessage Event Callback.vi and review the message handling code in each case.

Complete the following steps to review how UI messages are posted from an executing sequence:

  1. Open the example sequence file <TestStand Public>\Examples\Modifying User Interfaces\Handling UI Messages\UI Message Example.seq
  2. Inspect the statement steps. Each of these steps posts a UI message using the Thread.postUIMessageEx method.