Handling Messages - Casio ClassPad 300 Programming Manual

Sdk programming guide
Hide thumbs Also See for ClassPad 300:
Table of Contents

Advertisement

// Create Save Contact button
// The button gets created with ID SAVE_ID
b = new PegBitmapButton(rr, &gbsaveBitmap, SAVE_ID,AF_ENABLED|TT_COPY);
When this button is clicked, a unique message will be sent to the window's message
processing function that is formed by combining the Message Id PSF_CLICKED and the
object ID SAVE_ID. In the next section we will continue this example by showing how
this signal will be processed by the button's parent window.

Handling Messages

Any add-in that you write that must respond to user input will have to process
PegMessages and Signals. For a PegThing to respond to a message it must override the
following function:
virtual SIGNED Message(const PegMessage &Mesg);
This function is called by PegPresentationManager to allow an object to process a
message. This is the most commonly overridden of all PEG functions, because
customizing object behavior is done by adding your own message types and message
handling code to the default operation performed by PEG.
Overridden Message functions 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. In all other cases, Message()
should return 0 for normal operation.
In cases where you override a PEG class's Message() function, you should make sure
that you pass the messages you are not interested in down to the base class to insure that
normal default operation occurs, (unless of course you are specifically intercepting a
message to prevent some default operation!). In fact, if you decide to act on the receipt of
a PEG system message, you should generally pass the system message down to the base
class before you perform your own processing.
A typical Message() function for a derived class would appear as follows (assuming in
this example that the class is derived from CPWindow):
SIGNED 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;
28

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents