Share via


Flexible Dialog

Glossary Item Box

Microsoft Robotics Developer Studio Send feedback on this topic

Flexible Dialog

Flexible Dialog

Flexible Dialog - Icon

The Flexible Dialog service provides a way to create a simple Windows dialog box where you specify the types of controls that will appear in the dialog. You can access and update information that appears in the dialog dynamically, and respond to button presses.

Although it is possible to configure a Flexible Dialog at runtime, it is easiest to do this by selecting Set initial configuration for the service in the Properties toolbox and define the dialog’s configuration which will be loaded when the dialog starts.

Note that the dialog you define will be invisible unless you set its Visible property to true (in its configuration check the Visible checkbox) in the initial configuration. However, if the dialog is not initially needed in by your diagram it can be created invisible and displayed when needed by sending a Show request with the Show field set to true.

The dialog service provides two collections: Controls and Buttons. Controls are created in the same order as in the Controls collection moving downwards on the dialog window. For each control you can provide a set of parameters:

ID enables you to track updates to the controls (or modify them). It uses a string value.

ControlType is the type of control that appears. Note that buttons can appear here as well as in the Buttons collection.

Text is the text (string) that appears on the control. For labels, checkboxes, radio buttons, and buttons, it is the label shown for the control. If you want to define an access key (that enables a user to use Alt+key to access the control), include an ampersand (&) before the corresponding text character. For example, using &One for a control’s text label allows it to be accessed using Alt+O.

For comboboxes, Text is the text shown in the drop-down list for the control. To create multiple entries for the list, separate text by the vertical bar (|) character; for example, one|two|three.

For textboxes, multi-line textboxes, and separators this parameter is ignored.

Value is the value of the control. For textboxes and multi-line text boxes, this is the text that appears in the textbox. For checkboxes and radiobuttons, the value is a Boolean (true or false), that indicates whether the control is checked. For comboboxes, value is the selected item in the list. For labels this parameter is ignored.

In the Buttons collection, the ControlType is actually ignored and all controls in this collection are created as buttons.

Buttons are created in the same order as they appear in the Buttons collection across the bottom of the Form, but right-justified, i.e. if there is only one button it will appear at the bottom-right of the Form.

Controls in a Flexible Dialog always stretch to fill the width of the dialog. So if the user resizes the dialog, the controls will change width.

Unlike the Simple Dialog, the Flexible Dialog does not disappear when the user clicks on a define button. (It does close when a user clicks the dialog’s title bar 'X' Close button). If you want the dialog to disappear, you have to send it a Show request in response to the button press with the Show field set to false. Depending on your application, this can be useful because the dialog can remain on the screen as a control panel for your service.

The service provides the following requests.

Operation Description
ButtonPress A button press notification.
DeleteButton Deletes a specified button.
DeleteControl Deletes a specified control.
Get Returns the current state of the service.
HandOff Switches focus to another dialog (using the title of the target dialog).*
InsertButton Inserts a specified button.
InsertControl Inserts a specified control.
SetTitle Sets the title of the dialog window.
Show Displays or hides the dialog window.
UpdateButton Updates the state of a button.
UpdateControl Updates the state of a control or its contents.

*The state of a Flexible Dialog service can be also displayed as an HTML page. For example, when you access the Debug View for your project, a hyperlink to the service will appear the subscriptions list of your Diagram State section. Clicking that link will display an HTML page in a Web browser. If you use multiple instances of service, you can "hand off" or transfer the HTML view using the HandOff request to the current instance and passing the title of the new dialog.

While you can connect to the Response (Result) connection for the requests to confirm their success or failure (Fault), you more typically will want to use the Notification connection. With the exception of Get, the service also provides notifications for all requests. These not only generate notifications when you modify the dialog at runtime, but more importantly are the way you can detect and access data when the user interacts with the dialog. For example, if you want to know if the user clicks a button, use the ButtonPress notification. You can determine which button was pressed by checking the ID value returned (but remember to define an ID value for the button). For other controls such as radio buttons, checkboxes, and textboxes, use the UpdateControl notification. It will return not only the ID for the control, but also if its value was changed.

 

 

© 2012 Microsoft Corporation. All Rights Reserved.