CheckBox (statement)

Syntax

CheckBox X, Y, width, height, title$, .Identifier

Description

Defines a check box within a dialog box template.

Comments

Check box controls are either on or off, depending on the value of .Identifier.

This statement can only appear within a dialog box template (i.e., between the Begin Dialog and End Dialog statements).

The CheckBox statement requires the following parameters:

 

Parameter

Description

 

X, Y

Integer coordinates specifying the position of the control (in dialog units) relative to the upper left corner of the dialog box.

 

Width, height

Integer coordinates specifying the dimensions of the control in dialog units.

 

Title$

String containing the text that appears within the check box. This text may contain an ampersand character to denote an accelerator letter, such as "&Font" for Font (indicating that the Font control may be selected by pressing the F accelerator key).

 

Identifier

Name by which this control can be referenced by statements in a dialog function (such as DlgFocus and DlgEnable). This parameter also creates an integer variable whose value corresponds to the state of the check box (1 = checked; 0 = unchecked). This variable can be accessed using the syntax:

DialogVariable.Identifier.

 

When the dialog box is first created, the value referenced by .Identifier is used to set the initial state of the check box. When the dialog box is dismissed, the final state of the check box is placed into this variable. By default, the .Identifier variable contains 0, meaning that the check box is unchecked.

Example

This example displays a dialog box with two check boxes in different states.

Sub Main()

  Begin Dialog SaveOptionsTemplate 36,32,151,52,"Save"
    GroupBox 4,4,84,40,"GroupBox"
    CheckBox 12,16,67,8,"Include heading",.IncludeHeading
    CheckBox 12,28,73,8,"Expand keywords",.ExpandKeywords
    OKButton 104,8,40,14,.OK
    CancelButton 104,28,40,14,.Cancel
  End Dialog
  Dim SaveOptions As SaveOptionsTemplate
  SaveOptions.IncludeHeading = 1 'Check box initially on.
  SaveOptions.ExpandKeywords = 0 'Check box initially off.
  r% = Dialog(SaveOptions)
  If r% = -1 Then
    MsgBox "OK was pressed."
  End If
End Sub

See Also

CancelButton (statement); Dialog (function); Dialog (statement); 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).

Notes

Accelerators are underlined, and the accelerator combination Alt+letter is used.

More information

C