9.2. Make a Dialog Box Dynamic

The first thing to notice about the preceding script is that an identifier named DialogControl has been added to the Begin Dialog statement. As you will learn in the following subsection, this parameter to the Begin Dialog statement tells the Basic Control Engine to pass control to a function procedure named DialogControl.

Use a dialog function.

Respond to user actions.

Use a Dialog Function

Before the Basic Control Engine displays a custom dialog box by executing a Dialog statement or Dialog() function, it must first initialize the dialog box. During this initialization process, the Basic Control Engine checks to see whether you've defined a dialog function as part of your dialog box template. If so, the Basic Control Engine will give control to your dialog function, allowing your script to carry out certain actions, such as hiding or disabling dialog box controls.

After completing its initialization process, the Basic Control Engine displays your custom dialog box. When the user selects an item in a list box, clears a check box, or carries out certain other actions within the dialog box, the Basic Control Engine will again call your dialog function.

Responding to User Actions

The Basic Control Engine dialog function can respond to six types of user actions:

Action

Description

1

This action is sent immediately before the dialog box is shown for the first time.

2

This action is sent when:

 

A button is clicked, such as OK, Cancel, or a push button.

 

A check box's state has been modified

 

An option button is selected. In this case, ControlName$ contains the name of the option button that was clicked, and SuppValue contains the index of the option button within the option button group (0 is the first option button, 1 is the second, and so on).

 

The current selection is changed in a list box, drop list box, or combo box. In this case, ControlName$ contains the name of the list box, combo box, or drop list box, and SuppValue contains the index of the new item (0 is the first item, 1 is the second, and so on).

3

This action is sent when the content of a text box or combo box has been changed and that control loses focus.

4

This action is sent when a control gains the focus.

5

This action is sent continuously when the dialog box is idle. The user should return a 0 or idle processing will use up the CPU.

6

This action is sent when the dialog box is moved.

You'll find a more complete explanation of these action codes in the A–Z Reference. See the DlgProc (Function) entry in that documentation.

More information

9. Use a dynamic dialog box in a script.