Home |
Obtaining a Pointer to PegPresentationManager Determining the Position of an Object Overriding the Message() Method |
Overriding the Message() MethodOverriding the message handler method should in most cases return a result of 0. A non-zero return value is used to terminate modal window execution. PegWindow derived classes such as PegDialog and PegMessageWindow return non-zero results when a signal from a child control is received that causes the window to close. A Message() method should make sure that it passes the unhandled messages down to the base class to insure that normal default operation occurs, unless of course the message should be intercepted. For system messages, the base class's Message handler should be called first before any custom processing is done. A typical Message() function for a derived class would appear as follows (assuming in this example that the class is derived from PegWindow): PEGINT MyClass:Message(const PegMessage &Mesg) { switch (Mesg.wType) { case UIM_SHOW: PegWindow::Message(Mesg); // add your own code here: break; case USER_DEFINED_MSG1: // code for your user message break; 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 PegWindow::Message(Mesg); } return 0; }
|