# DI_BUTTON

The DI_BUTTON dialog item describes a Push Button control.

    struct FarDialogItem
    {
      int Type          = DI_BUTTON
      int X1            = X
      int Y1            = Y
      int X2            = 0 (not used in Dialog API 1.0)
      int Y2            = Y (equals to Y1)
      int Focus         = Focus
      int Selected      = Selected
      DWORD Flags       = Flags
      int DefaultButton = DefaultButton
      char Data[512]    = Button caption
    };

Attention!

- This is an exemplary structure; read full description here.

### Focus

Keyboard focus flag.

### Selected

If the button had focus when the user pressed <Enter> this field is set to 1.

### Flags

There are several flags applicable to the DI_BUTTON item:

Flag | Description
--- | ---
DIF_BTNNOCLOSE | Disables dialog closing after pressing the button.
DIF_CENTERGROUP | Sequential items having this flag set and equal vertical coordinates will be horizontally centered in the dialog. Their X1 and X2 coordinates are ignored. Useful for centering button groups.
DIF_NOBRACKETS | Display button titles without brackets.
DIF_SETCOLOR | The low byte of Flags will be used as the item color.
DIF_DISABLE | Disables user access to the control.
DIF_NOFOCUS | The dialog item cannot receive keyboard focus, but can handle other user events.
DIF_SHOWAMPERSAND | Show ampersand symbol in caption instead of using it for defining hotkeys.

### Event

Event | Description
--- | ---
DN_DRAWDLGITEM | This event is sent to the dialog callback function just before the button control is drawn.
DN_CTLCOLORDLGITEM | The plugin should pass the color attributes of the button when this event arrives. Param2 argument (foreground+background):
    LoWord LoByte - color of the caption
                    (COL_WARNDIALOGBUTTON or
         COL_DIALOGBUTTON)
    LoWord HiByte - color of highlighted text
                    (COL_WARNDIALOGHIGHLIGHTBUTTON or
         COL_DIALOGHIGHLIGHTBUTTON)

    Param2, when the button has focus:

    LoWord LoByte - color of the caption
                    (COL_WARNDIALOGSELECTEDBUTTON or
         COL_DIALOGSELECTEDBUTTON)
    LoWord HiByte - color of highlighted text
                    (COL_WARNDIALOGHIGHLIGHTSELECTEDBUTTON or
         COL_DIALOGHIGHLIGHTSELECTEDBUTTON)
    HiWord LoByte - 0
    HiWord HiByte - 0
If the special DIF_SETCOLOR flag is used, then the button's caption (LoWord LoByte) will be drawn according to the above settings.
DN_KEY | This event comes after the user has pressed a key in the dialog.
DN_HOTKEY | A hotkey was pressed (Alt-<letter>).
DN_MOUSECLICK | This event comes after the user has clicked one of the dialog items or outside the dialog with a mouse button.
DN_BTNCLICK | The button was pressed.
DN_KILLFOCUS | This event is sent before the button loses the focus, if the flag DIF_NOFOCUS was not used.
DN_GOTFOCUS | This event is sent after the button has received the keyboard focus, if the flag DIF_NOFOCUS was not used.

### Remarks

The FarDialogItem structure is described assuming the use of named unions. For more information, see _FAR_NO_NAMELESS_UNIONS.
See also:
DI_CHECKBOX, DI_RADIOBUTTON, FarDialogItem