PushButton (statement)


PushButton X,Y,width,height,title$ [,.Identifier]


Defines a push button within a dialog box template.


Choosing a push button causes the dialog box to close (unless the dialog function redefines this behavior).

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

The PushButton statement accepts the following parameters:





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.



String containing the text that appears within the push button. This text may contain an ampersand character to denote an accelerator letter, such as "&Save" for Save.



Name by which this control can be referenced by statements in a dialog function (such as DlgFocus and DlgEnable).


If a push button is the default button, it can be selected by pressing Enter on a nonbutton control.

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


This example creates a bunch of push buttons and displays which button was pushed.

Sub Main()
  Begin Dialog ButtonTemplate 17,33,104,84,"Buttons"
    OKButton 8,4,40,14,.OK
    CancelButton 8,24,40,14,.Cancel
    PushButton 8,44,40,14,"1",.Button1
    PushButton 8,64,40,14,"2",.Button2
    PushButton 56,4,40,14,"3",.Button3
    PushButton 56,24,40,14,"4",.Button4
    PushButton 56,44,40,14,"5",.Button5
    PushButton 56,64,40,14,"6",.Button6
  End Dialog
  Dim ButtonDialog As ButtonTemplate
  WhichButton% = Dialog(ButtonDialog)
  MsgBox "You pushed button " & WhichButton%
End Sub

See Also

CancelButton (statement); CheckBox (statement); ComboBox (statement); Dialog (function); Dialog (statement); DropListBox (statement); GroupBox (statement); ListBox (statement); OKButton (statement); OptionButton (statement); OptionGroup (statement); Picture (statement); Text (statement); TextBox (statement); Begin Dialog (statement), PictureButton (statement); DlgSetPicture (statement).


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

More information