case USER_DEFINED_MSG2:
// code for another user defined message:
break;
case SIGNAL(IDB_OK, PSF_CLICKED):
// code for OK button clicked:
break;
default:
// pass all other messages down to the base class:
return CPWindow::Message(Mesg);
}
return 0;
}
In the previous section, we created a button with Object ID SAVE_ID. To catch the
signal that this button sends, our Message function would look like this:
SIGNED AddressWindow:Message(const PegMessage &Mesg)
{
switch (Mesg.wType)
{
case SIGNAL(SAVE_ID, PSF_CLICKED):
// code for Save button clicked:
Save();
break;
default:
// pass all other messages down to the base class:
return CPWindow::Message(Mesg);
}
return 0;
}
It is recommended that you refer back to the AddressBook example to get more
information about how to create an overridden Message() function.
Message Flow and Routing
PEG follows a bottom-up message flow philosophy. This means that whenever possible
messages pulled from PegMessageQueue are sent directly to the lowest level object that
should receive the message. If the object does not act on the message, it is passed ‘up the
chain’ to its parent, which may be any other type of object, such as a PegGroup or
PegWindow. This flow continues until either an object processes the message, or the
message arrives at PegPresentationManager. If a user-defined message arrives at
PegPresentationManager, it will be ignored. This occurrence is usually an indication that
you forgot to catch a message in one of your window classes.
29