Dialog (function)

Syntax

Dialog(DialogVariable [,[DefaultButton] [,Timeout]])

Description

Displays the dialog box associated with DialogVariable, returning an Integer indicating which button was clicked.

Comments

The function returns any of the following values:

 

-1

The OK button was clicked.

 

0

The Cancel button was clicked.

 

>0

A push button was clicked. The returned number represents which button was clicked based on its order in the dialog box template (1 is the first push button, 2 is the second push button, and so on).

 

The Dialog function accepts the following parameters:

 

Parameter

Description

 

DialogVariable

Name of a variable that has previously been dimensioned as a user dialog box. This is accomplished using the Dim statement:

 

 

 Dim MyDialog As MyTemplate

All dialog variables are local to the Sub or Function in which they are defined. Private and public dialog variables are not allowed.

 

DefaultButton

An Integer specifying which button is to act as the default button in the dialog box. The value of DefaultButton can be any of the following:

 

 

-2

This value indicates that there is no default button.

 

 

-1

This value indicates that the OK button, if present, should be used as the default.

 

 

0

This value indicates that the Cancel button, if present, should be used as the default.

 

 

>0

This value indicates that the Nth button should be used as the default. This number is the index of a push button within the dialog box template.

 

 

 

If DefaultButton is not specified, then -1 is used. If the number specified by DefaultButton does not correspond to an existing button, then there will be no default button.

The default button appears with a thick border and is selected when the user presses Enter on a control other than a push button.

 

Timeout

An Integer specifying the number of milliseconds to display the dialog box before automatically dismissing it. If TimeOut is not specified or is equal to 0, then the dialog box will be displayed until dismissed by the user.

If a dialog box has been dismissed due to a timeout, the Dialog function returns 0.

Example

This example displays an abort/retry/ignore disk error dialog box.

Sub Main()

  Begin Dialog DiskErrorTemplate 16,32,152,48,"Disk Error"
    Text 8,8,100,8,"The disk drive door is open."
    PushButton 8,24,40,14,"Abort",.Abort
    PushButton 56,24,40,14,"Retry",.Retry
    PushButton 104,24,40,14,"Ignore",.Ignore
  End Dialog
  Dim DiskError As DiskErrorTemplate
  r% = Dialog(DiskError,3,0)
  MsgBox "You selected button: " & r%
End Sub

See Also

CancelButton (statement); CheckBox (statement); ComboBox (statement); Dialog (statement); DlgProc (function); DropListBox (statement); GroupBox (statement); ListBox (statement); OKButton (statement); OptionButton (statement); OptionGroup (statement); Picture (statement); PushButton (statement); Text (statement); TextBox (statement); Begin Dialog (statement), PictureButton (statement).

More information

D