These macros provide different methods for handling child ID notification
codes. If you want child ID notifications to be handled at the child’ parents
window use EV_CHILD_NOTIFY which passes the notification code as a, ,
parameter and lets multiple child ID notifications be handled with a single
function. This also prevents having to handle each child’ notifications
message in separate response tables for each control. Instead, each message
is handled at the parent, enabling, for example, a dialog box to handle all
its controls in its response table.
For example, suppose you have a dialog box called TT stDialog that hase
four buttons. The buttons IDs are ID_BUTTON1, ID_BUTTON2,
ID_BUTTON3, and ID_BUTTON4. When the user clicks a button, you want
a single function to handle the event, regardless of which button was
pressed. If the user double-clicks a button, you want a special function to
handle the event. The code would look like this:
class TTestDialog : public TDialog {
public:
TTestDialog(TWindow* parent, TResId resId);
void HandleClick();
void HandleDblClick1();
void HandleDblClick2();
void HandleDblClick3();
void HandleDblClick4();
DECLARE_RESPONSE_TABLE(TTestDialog);
};
DEFINE_RESPONSE_TABLE1(TTestDialog, TDialog)
EV_CHILD_NOTIFY(ID_BUTTON1, BN_CLICKED, HandleClick),
EV_CHILD_NOTIFY(ID_BUTTON2, BN_CLICKED, HandleClick),
EV_CHILD_NOTIFY(ID_BUTTON3, BN_CLICKED, HandleClick),
EV_CHILD_NOTIFY(ID_BUTTON4, BN_CLICKED, HandleClick),
EV_CHILD_NOTIFY(ID_BUTTON1, BN_DOUBLECLICKED, HandleDblClick1),
EV_CHILD_NOTIFY(ID_BUTTON2, BN_DOUBLECLICKED, HandleDblClick2),
EV_CHILD_NOTIFY(ID_BUTTON3, BN_DOUBLECLICKED, HandleDblClick3),
EV_CHILD_NOTIFY(ID_BUTTON4, BN_DOUBLECLICKED, HandleDblClick4),
END_RESPONSE_TABLE;
If you want all notification codes from the child to be passed to the parent
window use EV_CHILD_NOTIFY_ALL_CODES, the generic handler for,
child ID notifications. For example, the sample program BUTTONX.CPP
defines this response table:
Chapter 5, Event handling
149