DlgControlId (function)




Returns an Integer containing the index of the specified control as it appears in the dialog box template.


The first control in the dialog box template is at index 0, the second is at index 1, and so on.

The ControlName$ parameter contains the name of the .Identifier parameter associated with that control in the dialog box template.


The Basic Control Engine statements and functions that dynamically manipulate dialog box controls identify individual controls using either the .Identifier name of the control or the control's index. Using the index to refer to a control is slightly faster but results in code that is more difficult to maintain.


This example uses DlgControlId to verify which control was triggered and branches the dynamic dialog script accordingly.

Function DlgProc(ControlName$,Action%,SuppValue%) As Integer

  If Action% = 2 Then
    'Enable the next three controls.
    If DlgControlId(ControlName$) = 2 Then
      For i = 3 to 5
        DlgEnable i,DlgValue("CheckBox1")
      Next i
      DlgProc = 1  'Don't close the dialog box.
    End If
 ElseIf Action% = 1 Then
    'Set initial state upon startup
    For i = 3 to 5
      DlgEnable i,DlgValue("CheckBox1")
    Next i
  End If
End Function


Sub Main()

  Begin Dialog UserDialog ,,180,96,"Untitled",.DlgProc
    OKButton 132,8,40,14
    CancelButton 132,28,40,14
    CheckBox 24,16,72,8,"Click Here",.CheckBox1
    CheckBox 36,32,60,8,"Sub Option 1",.CheckBox2
    CheckBox 36,44,72,8,"Sub Option 2",.CheckBox3
    CheckBox 36,56,60,8,"Sub Option 3",.CheckBox4
    CheckBox 24,72,76,8,"Main Option 2",.CheckBox5
  End Dialog
  Dim d As UserDialog
  Dialog d
End Sub

See Also

DlgEnable (function); DlgEnable (statement); DlgFocus (function); DlgFocus (statement); DlgListBoxArray (function); DlgListBoxArray (statement); DlgSetPicture (statement); DlgText (statement); DlgText$ (function); DlgValue (function); DlgValue (statement); DlgVisible (statement); DlgVisible (function).

More information