connectButtonNotify

>>--connectButtonNotify(--id--,--"--event---"--+---------------+--)---------><
                                               +-,--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

A keyword specifying the event to be connected with a method. This can be exactly one of the follwoing:

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).

HOTITEM

Notifies the dialog that the mouse has moved over the button, or that the mouse is leaving the area over the button.

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, a message name is generated automatically. The name consists of the event keyword preceded by On. For instance: onGotFocus.

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.

Additional Notes:

  1. The invocation of connectButtonNotify() can be placed in the init or initDialog method. (Indeed the invocation can be done anywhere. But, it makes most sense to have the connection made before the dialog starts executing.) If the connection is made in the init() method, be sure that the super class init() is invoked first.

  2. For all events other than the HOTITEM event, the event-handling methods will receive two arguments. The first arg contains information about the specific control and its event. The second arg is the window handle of the button control.

    The low word of the first arg is the control ID and the high word is the event ID. Example:

    ::method handler
      use arg info, handle
      id = .DlgUtil~loWord(info)
      ...

  3. The method for the HOTITEM event also receives two arguments. The first arg is the control id. The second arg is .true or .false. True if the mouse moved over the button, false if it left the area over the button. Example:

    ::method onHover
      use arg id, entering
      say 'onHover id:' id 'entering:' entering
      ...
    
    /* Output might be:
    
      onHover id: 1044 entering: 1
      onHover id: 1044 entering: 0
      onHover id: 1001 entering: 1
      onHover id: 1001 entering: 0
    
    */

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"