DialogFunc Prototype

Syntax

Function dialogfunc(DlgItem$, Action%, SuppValue?) _
     As Boolean
    Select Case Action%
    Case 1 ' dialog initialization
        ...
    Case 2 ' Value changing or button pressed
        ...
    Case 3 ' TextBox or ComboBox text changed
        ...
    Case 4 ' Focus changed
        ...
    Case 5 ' Idle
        ...
    Case 6 ' Function key
        ...
    End Select
End Function

Group

Dialog Function

Description

A dialogfunc implements the dynamic dialog capabilities.

Parameters

Parameters Description
DlgItem This string value is the name of the user dialog item's field.
Action This numeric value indicates what action the dialog function is being asked to do.
SuppValue This numeric value provides additional information for some actions.

Actions

Action Description
1 dialog initialization. DlgItem is a null string. SuppValue is the dialog's window handle. Set dialogfunc = True to terminate the dialog.
2 CheckBox, DropListBox, ListBox, MultiListBox or OptionGroup: DlgItem's value has changed. SuppValue is the new value.
CancelButton, OKButton or PushButton: DlgItem's button was pushed. SuppValue is meaningless. Set dialogfunc = True to prevent the dialog from closing.
3 ComboBox or TextBox: DlgItem's text changed and losing focus. SuppValue is the number of characters.
4 Item DlgItem is gaining focus. SuppValue is the item that is losing focus. (The first item is 0, second is 1, etc.)
5 Idle processing. DlgItem is a null string. SuppValue is zero. Set dialogfunc = True to continue receiving idle actions. The idle action is called as often as possible. Use Wait .1 to reduce the number of idle calls to 10 per second.
6 Function key (F1-F24) was pressed. DlgItem has the focus. SuppValue is the function key number and the shift/control/alt key state.
Regular function keys range from 1 to 24.
Shift function keys have &H100 added.
Control function keys have &H200 added.
Alt function keys have &H400 added.
(Alt-F4 closes the dialog and is never passed to the Dialog Function.)

See also

Begin Dialog


Sub Main
    Begin Dialog UserDialog 200,120,.DialogFunc
        Text 10,10,180,15,"Please push the OK button"
        TextBox 10,40,180,15,.Text
        OKButton 30,90,60,20
        PushButton 110,90,60,20,"&Hello"
    End Dialog
    Dim dlg As UserDialog
    Debug.Print Dialog(dlg)
End SubFunction DialogFunc(DlgItem$, Action%, SuppValue?) As Boolean
    Debug.Print "Action="; Action%
    If Action% <> 1 And Action% <> 5 Then
        Debug.Print DlgItem$'; "="""; DlgText(DlgItem$); """"
    End If
    Debug.Print "SuppValue="; SuppValue?
    Select Case Action%
    Case 1 ' Dialog box initialization
        Beep
    Case 2 ' Value changing or button pressed
        If DlgItem$ = "Hello" Then
            MsgBox "Hello"
            DialogFunc = True 'do not exit the dialog
        End If
    Case 4 ' Focus changed
        Debug.Print "DlgFocus="""; DlgFocus(); """"
    Case 6 ' Function key
        If SuppValue? And &H100 Then Debug.Print "Shift-";
        If SuppValue? And &H200 Then Debug.Print "Ctrl-";
        If SuppValue? And &H400 Then Debug.Print "Alt-";
        Debug.Print "F" & (SuppValue And &HFF)
    End Select
End Function