CancelButton (statement)

Syntax

CancelButton X, Y, width, height [,.Identifier]

Description

Defines a Cancel button that appears within a dialog box template.

Comments

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

Selecting the Cancel button (or pressing Esc) dismisses the user dialog box, causing the Dialog function to return 0. (Note: A dialog function can redefine this behavior.) Pressing the Esc key or double-clicking the close box will have no effect if a dialog box does not contain a CancelButton statement.

The CancelButton 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.

 

Identifier

Optional parameter specifying the name by which this control can be referenced by statements in a dialog function (such as DlgFocus and DlgEnable). If omitted, then the word Cancel is used.

 

A dialog box must contain at least one OKButton, CancelButton, or PushButton statement; otherwise, the dialog box cannot be dismissed.

Example

This example creates a sample dialog box with OK and Cancel buttons.

Sub Main()

  Begin Dialog QuitDialogTemplate 16,32,116,64,"Quit"
    Text 4,8,108,8,"Are you sure you want to exit?"
    CheckBox 32,24,63,8,"Save Changes",.SaveChanges
    OKButton 12,40,40,14
    CancelButton 60,40,40,14
  End Dialog
  Dim QuitDialog As QuitDialogTemplate
  rc% = Dialog(QuitDialog)
  Select Case rc%
    Case -1
      MsgBox "OK was pressed!"
    Case 1
      MsgBox "Cancel was pressed!"
  End Select
End Sub

See Also

CheckBox (statement); ComboBox (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).

More information

C