ConnectButtonNotify

>>-aMessageExtensions~ConnectButtonNotify(--id--,--"--+-CLICKED---+--"-->
                                                      +-DBLCLK----+
                                                      +-DISABLE---+
                                                      +-GOTFOCUS--+
                                                      +-LOSTFOCUS-+
                                                      +-HILITE----+
                                                      +-UNHILITE--+
                                                      +-PAINT-----+

>--+---------------+--)----------------------------------------><
   +-,--msgToRaise-+


The ConnectButtonNotify method connects a particular WM_NOTIFY message for a button control (push button, radio button, or check box) with a method. The WM_NOTIFY message informs the dialog that an event has occurred with regard to the button.

Note: In order to recieve the GOTFOCUS, LOSTFOCUS, and DBLCLK events, the button control has to have the NOTIFY (BS_NOTIFY) style. For user defined dialogs use the NOTIFY style keyword in the Add... method when the button is defined. For dialogs created from a compiled resource or a resource script file use the BS_NOTIFY style for the button resource. The other events are always sent and it is not necessary to add the NOTIFY style.

Arguments:

The arguments are:

id

The ID of the button control of which a notification is to be connected to a method.

event

The event to be connected with a method:

CLICKED

The button has been clicked.

DBLCLK

The button has been double-clicked.

DISABLE

The button has been disabled.

GOTFOCUS

The button got the input focus.

LOSTFOCUS

The button lost the input focus.

HILITE

The button has been selected.

UNHILITE

The highlighting is to be removed (lost selection).

PAINT

The button is to be repainted. This notification is only sent for owner-drawn buttons.

msgToRaise

The message that is to be sent whenever the specified notification is received from the button control. Provide a method with a matching name. If you omit this argument, the event is preceded by On.

Return value:

The return codes are:

0

No error detected.

-1

The resource ID could not be resolved or the event argument is incorrect.

1

The message was not connected correctly.

Example:

The following example displays a message whenever the OK button is selected:

::class MyDlgClass subclass UserDialog inherit MessageExtensions

::method Init
  self~init:super(...)
  self~ConnectButtonNotify("OK", "HILITE")

::method OnHilite
  say "The OK button has been selected"

  1. Connections are usually placed in the Init or InitDialog method. If both methods are defined, use init as the place for this connection - but not before init:super has been called.

  2. The event-handling methods receive two arguments: the ID of the button (extract the low-order word) and the handle to the button. Example:

    ::method Handler
      use arg ev_id, handle
      id = BinaryAnd(ev_id, "0x0000FFFF")
      ...