Home > Language Reference > User Dialog Functions > BeginDialog

BeginDialog

The BeginDialog...EndDialog function creates a user dialog form.

Usage

Used to input data needed by the script. To create a dialog box, use the Insert/Dialog box menu.

Syntax

BEGINDIALOG <dialog_name> <x>,<y>,<width>,<height>
        CAPTION <dialog_title>
        PUSHBUTTON <button_name>,<button_click>,<x>,<y>,<width>,<height>
        DEFPUSHBUTTON <button_name>,<button_click>,<x>,<y>,<width>,<height>
        EDITTEXT Edit$,<x>,<y>,<width>,<height>[,protected]
        TEXT <message_text>,<x>,<y>
        COMBOBOX <string_array()>,<x>,<y>,<width>,<height>,selection$[,Sorted]
        LISTBOX <string_array()>,<x>,<y>,<width>,<height>,selection$[,Sorted]
        GROUPBOX [<groupbox_name>,]<x>,<y>,<width>,<height>
        CHECK <checkbox_name>,<check_click>,<x>,<y>
        RADIO <radiobutton_name,<radio_click>,<x>,<y>
        ICON <icon_type>,<x>,<y>,<width>,<height>
    ENDDIALOG

Parameters

<dialog_name>, label of the dialog box ; this label is used later in the script in order to display the dialog box. The label cannot be a variable.

<x>,<y>,<width>,<height>, coordinates of the top-left point of the dialog box, width and height of the dialog box.

On the CAPTION line, the title of the dialog box is specified. The title cannot be a variable.

The controls that you can put on a dialog are:
 Control  Description
 PUSHBUTTON  Button
 DEFPUSHBUTTON  Default button    
 EDITTEXT          Edit field
 TEXT  Text field
 COMBOBOX      Combobox field
 LISTBOX  Listbox field
 GROUPBOX      Group of controls
 CHECK      Checkbox    
 RADIO  Radio button
 ICON  Icon

The parameters for each control are explained below and an example is given.

PUSHBUTTON and DEFPUSHBUTTON

BEGINDIALOG <dialog_name> <x>,<y>,<width>,<height>
        CAPTION <dialog_title>
        PUSHBUTTON <button_name>,<button_click>,<x>,<y>,<width>,<height>
    ENDDIALOG


<button_name>, constant, string, text of the button to display in the dialog box. If DEFPUSHBUTTON keyword is used, <button_name> is the default button. If not, use PUSHBUTTON keyword.

<button_click>, variable, integer. The return value is 1 if the button has been clicked, 0 if not.

<x>,<y>,<width>,<height>, integers, coordinates of the button relative to the top-left point of the dialog box, width and height of the button.

BEGINDIALOG Dialog1 225, 176, 240, 153
        CAPTION "Example"
        DEFPUSHBUTTON "&OK", btnok, 57, 47, 59, 22
        PUSHBUTTON "&Cancel", btncancel, 143, 43, 47, 28
    ENDDIALOG
    'Display the Dialog box labeled Dialog1
    CallDialog Dialog1
    If btnok=1 then
      msgbox("OK button clicked")
    endif
    if btncancel=1 then
      msgbox("Cancel button clicked")
    endif

EDITTEXT

    BEGINDIALOG <dialog_name> <x>,<y>,<width>,<height>
        CAPTION <dialog_title>
        EDITTEXT Edit$, <x>,<y>,<width>,<height>[,protected]
    ENDDIALOG

        
Edit$, variable, string. This returned variable contains the text typed by the user in the Edit field.

<x>,<y>,<width>,<height>, integers, coordinates of the Edit field relative to the top-left point of the dialog box, width and height of the Edit field.

protected, optional keyword. If specified, the Edit field is a password field (hidden with asterisks).

BEGINDIALOG Dialog1 225, 176, 240, 153
        CAPTION "Enter your user information"
         EDITTEXT Edit$, 64, 25, 107, 20
         DEFPUSHBUTTON "&OK", btnok, 57, 47, 59, 22
    ENDDIALOG
'Display the Dialog box labeled Dialog1
    CallDialog Dialog1
    msgbox(Edit$)


TEXT

    BEGINDIALOG <dialog_name> <x>,<y>,<width>,<height>
            CAPTION <dialog_title>
            TEXT <message_text>,<x>,<y>
        ENDDIALOG


<message_text>, string, text to display.

<x>,<y>, integers, coordinates of the topleft point of the text.

    BEGINDIALOG Dialog1 225, 176, 240, 153
        CAPTION "Information"
        TEXT "Thanks to read this and click OK", 64, 25
        DEFPUSHBUTTON "&OK", btnok, 57, 47, 59, 22
     ENDDIALOG
    'Display the Dialog box labeled Dialog1
    CallDialog Dialog1



COMBOBOX and LISTBOX

    BEGINDIALOG <dialog_name> <x>,<y>,<width>,<height>
        CAPTION <dialog_title>
        COMBOBOX <string_array()>,<x>,<y>,<width>,<height>,Selection$[,Sorted]
        LISTBOX <string_array()>,<x>,<y>,<width>,<height>,Selection$[,Sorted]

        ENDDIALOG


<string_array()>, array of strings. It contains the listbox/combobox values. You must define the array first using the DIM statement. Array indexing starts at 0.

<x>,<y>,<width>,<height>, integers, coordinates of the field relative to the top-left point of the dialog box, width and height of the field.

Selection$, variable, string. This returned value contains the list/combo item selected by the user.

Sorted, optional keyword. If specified, the list/combo values are sorted.

'Declare the array containing the different values for the listbox
    Dim data$(10)
    'Fill the array
    data$(0)="First value"
    data$(1)="Second value"
    data$(2)="Third value"
    BEGINDIALOG Dialog1 225, 176, 240, 189
        CAPTION "Select a value in the list"
        LISTBOX data$(), 124, 14, 80, 67, selection$
        DEFPUSHBUTTON "&OK", btnok, 24, 115, 59, 22
    ENDDIALOG
    'Display the dialog labeled Dialog1
    CallDialog Dialog1
    'Display the listbox user selection
    msgbox(selection$)

GROUPBOX

    BEGINDIALOG <dialog_name> <x>,<y>,<width>,<height>
        CAPTION <dialog_title>
        GROUPBOX [<groupbox_name>,]<x>,<y>,<width>,<height>
        ENDDIALOG


<groupbox_name>, optional, string, text for the frame title.

<x>,<y>,<width>,<height>, integers, coordinates of the frame relative to the top-left point of the dialog box, width and height of the frame.

BEGINDIALOG Dialog1 225, 176, 240, 189
        CAPTION "Check one radio button in the frame"
         GROUPBOX "Frame Title",43, 23, 72, 65
         DEFPUSHBUTTON "&OK", btnok, 24, 115, 59, 22
    ENDDIALOG
    'Display the dialog labeled Dialog1
    CallDialog Dialog1

    
CHECK and RADIO

    BEGINDIALOG <dialog_name> <x>,<y>,<width>,<height>
        CAPTION <dialog_title>
        
CHECK <checkbox_name>,<check_click>,<x>,<y>
        RADIO <radiobutton_name,<radio_click>,<x>,<y>

        ENDDIALOG


<checkbox_name> or <radiobutton_name>, string, text of the checkbox/radio button to display in the dialog box.

<check_click> or <radio_click>, variable, integer. The return value is 1 if the radio/checkbox has been clicked, 0 if not.

<x>,<y>, integers, coordinates of the radio/checkbox relative to the top-left point of the dialog box.

BEGINDIALOG Dialog1 225, 176, 240, 189
        CAPTION "Radio button and Checkbox"
        RADIO "Radio On/Radio Off", Radio1, 56, 25
        CHECK "On/Off", Check1, 59, 65
        DEFPUSHBUTTON "&OK", btnok, 24, 115, 59, 22
    ENDDIALOG
    'Display the dialog labeled Dialog1
    CallDialog Dialog1
    If radio1 = 1 then
        msgbox("Radio button checked")
    Else
        msgbox("Radio button unchecked")
    EndIf
    If check1 = 1 then
        msgbox("Checkbox checked")
    Else
        msgbox("Checkbox unchecked")
    EndIf

ICON

    BEGINDIALOG <dialog_name> <x>,<y>,<width>,<height>
                CAPTION <dialog_title>
        
ICON <icon_type>,<x>,<y>,<width>,<height>
    ENDDIALOG


<icon_type>, constant, string. The allowed values for this constant are
 <icon_type>  Description
 "Stop"  Red cross icon
 "Info"      I icon
 "Exclamation"  ! icon
 "Question"  ? icon
 "Winlogo"      Windows logo icon

<x>,<y>,<width>,<height>, integers, coordinates of the icon relative to the top-left point of the dialog box, width and height of the icon.

    BEGINDIALOG Dialog1 225, 176, 240, 189
        CAPTION "Icon"
        ICON "Stop", 145, 100, 32, 32
        DEFPUSHBUTTON "&OK", btnok, 24, 115, 59, 22
    ENDDIALOG

    'Display the dialog labeled Dialog1
    CallDialog Dialog1