DI_CHECKBOX

Far Manager

DI_CHECKBOX

The DI_CHECKBOX dialog item describes a Check Box control. It is also known as a "button with independent fixation" or an "on/off switch". The switch is considered to be ON when the dialog item has non-zero Selected field.
struct FarDialogItem
{
  int Type          = DI_CHECKBOX
  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]    = Checkbox caption
};

Attention! Attention!

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

Focus

Keyboard focus flag.

Selected

This field reflects current state of the checkbox control: is it switched on or off.

Flags

There are several flags applicable to the DI_CHECKBOX item:
FlagDescription
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 checkbox groups.

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_3STATE The checkbox will have 3 possible states: "off", "on", "undefined".
DIF_SHOWAMPERSAND Show ampersand symbol in caption instead of using it for defining hotkeys.

Events

EventDescription
DN_DRAWDLGITEM This event is sent to the dialog callback function just before the control is drawn.
DN_CTLCOLORDLGITEM The plugin should pass the color attributes of the checbox when this event comes. 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 checkbox 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 flag DIF_SETCOLOR is used, the checkbox's caption (LoWord LoByte) will be drawn according to the above settings.
DN_HOTKEY A hotkey was pressed (Alt-<letter>).
DN_BTNCLICK The state of the checkbox was changed.
DN_KEY This event comes after the user has pressed a key in the dialog.
DN_MOUSECLICK This event comes after the user has clicked one of the dialog items or outside the dialog with a mouse button.
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

It is strongly recommended to set correct values for X2 and Y2 fields, though they aren't used in Dialog API 1.0.
See also: