connectStaticNotify

>>--connectStaticNotify(--id--,--"event"--,-+---------------+--)--------><
                                            +-,--methodName-+

The connectStaticNotify connects a notification message from a static control to a method, defined by the programmer, of the dialog. Normally, static controls do not send notification messages. A static control will only send the messages when it has the SS_NOTIFY style. The notification messages inform the dialog that an event has occurred with regard to the static control.

For user defined dialogs use the NOTIFY style keyword in the Add... static control methods when the control is defined. For dialogs created from a compiled resource or a resource script file use the SS_NOTIFY style when defining the control in a resource editor.

Arguments:

The arguments are:

id

The resource ID of the static control.

event

A keyword specifying the event to be connected with a method:

CLICK

The static control has been clicked with the mouse.

DBLCLK

The static control has been double-clicked with the mouse.

DISABLE

The static control has been disabled.

ENABLE

The static control has been enabled.

methodName

The method that is to be invoked whenever the specified notification is received from the static control. The programmer defines this method. If this argument is omitted, a method name is automatically generated that consists of the event keyword preceded by on. For instance, onClick.

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 connectStaticNotify() 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. The defined 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 static control.

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

Example:

The following example comes from an application that displays employee statistics. A single click on the employee number field advances the display to the next employee. A double click on either the employee name or employee job duties alllows those fields to be edited.

::method initDialog

  self~connectStaticNotify(IDC_ST_EMPNO, "CLICK", empLookup)

  self~connectStaticNotify(IDC_ST_EMPJOB, "DBLCLK", editStats)
  self~connectStaticNotify(IDC_ST_EMPNAME, "DBLCLK", editStats)

  first = self~initDatabase
  self~setStats(first)

In this example, (a continuation of the above example,) the control ID determines if the user has double clicked on the employee job duties field, or the employee name field. The event ID is not used, or needed. Its purpose in the code snippet is simply an example. The same thing applies to the window handle.

::method editStats
  use arg ctrlInfo, ctrlHwnd

  ctrlID = .DlgUtil~loWord(ctrlInfo)
  eventID = .DlgUtil~hiWord(ctrlInfo)

  rec = self~getCurrentRecord

  if self~userUpdate(ctrlID, rec) then self~setStats(rec)