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.
The arguments are:
The ID of the button control of which a notification is to be connected to a method.
A keyword specifying the event to be connected with a method. This can be exactly one of the follwoing:
The button has been clicked.
The button has been double-clicked.
The button has been disabled.
The button got the input focus.
The button lost the input focus.
The button has been selected.
The highlighting is to be removed (lost selection).
Notifies the dialog that the mouse has moved over the button, or that the mouse is leaving the area over the button.
The button is to be repainted. This notification is only sent for owner-drawn buttons.
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.
The return codes are:
No error detected.
The resource ID could not be resolved or the event argument is incorrect.
The message was not connected correctly.
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.
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) ...
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 */
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"