KwikPeg Manuals
Home
PegMLMessageWindow
Examples
Examples
Index
Index


Members
Styles
Signals
(none)
Overview Derived from class PegWindow

The PegMLMessageWindow class provides a a popup window for displaying warning, error or other status information to the user.

The PegMLMessageWindow class provides a simple way to display information messages. A message window may contain an optional title bar, an optional bitmap icon, a message text line and control buttons with which the user can close the window.

The PegMLMessageWindow class supports modal and non-modal execution. A message window executes as a modal window when your application calls the window's Execute() member function. If the message window has no parent, it will be added to the invisible window maintained by the KwikPeg Presentation Manager, making the message window a top-level window.

Because message windows are intended for interaction with a user, special message buttons (objects) can be automatically added to the message window using message window style flags. Each of these buttons is identified by one of the reserved KwikPeg object IDs as indicated in the following table.

Button Style Object ID
OK MW_OK IDB_OK
Yes MW_YES IDB_YES
No MW_NO IDB_NO
Cancel MW_CANCEL IDB_CANCEL
Abort MW_ABORT IDB_ABORT
Retry MW_RETRY IDB_RETRY

When an object with one of these reserved object IDs is selected, the message window will be closed. The message window sends a PM_MWCOMPLETE message to its parent window to indicate that the message window has been closed. The message iData member will contain the object ID of the object that forced closure of the message window. In all cases, the message window will be closed after the parent window has received the PM_MWCOMPLETE message.

If the message window is being executed modally, the Execute() member function will return to its caller, passing it the object ID of the button (object) that forced the message window to close.

When a message window is closed, the PM_MWCOMPLETE message is normally directed to the message window's parent. However, when a message window is created, you can specify an alternate Owner window which will receive the closure notification instead of the parent.

Custom message window classes can be derived from the PegMLMessageWindow class. In particular, note that a PegMLMessageWindow object can also be closed by signals from objects (buttons) with the reserved object IDs of IDB_CLOSE and IDB_APPLY. However, unlike a dialog window of the PegDialog class, a message window will be closed upon receipt of a signal from an object with ID IDB_APPLY.



 See Also

PegDialog

PegMessageWindow



 Styles

The PegMLMessageWindow class supports the following style flags:

FF_NONE No frame.
FF_THIN Thin frame.
FF_THICK Thick 3D frame.
FF_RAISED Raised 3D frame.
FF_RECESSED Recessed 3D frame.
MW_OK Adds an OK button to the window.
MW_YES Adds a YES button to the window.
MW_NO Adds a NO button to the window.
MW_ABORT Adds an ABORT button to the window.
MW_RETRY Adds a RETRY button to the window.
MW_CANCEL Adds a CANCEL button to the window.

Top of page


 Members

Constructors:

PegMLMessageWindow(const PegRect &Rect,
  const PEGCHAR *Title,
  const PEGCHAR *Message = NULL,
  WORD wStyle = MW_OK|FF_RAISED,
  PegBitmap *pIcon = NULL,
  PegThing *Owner = NULL)
PegMLMessageWindow(const PEGCHAR *Title,
  const PEGCHAR *Message = NULL,
  WORD wStyle = MW_OK|FF_RAISED,
  PegBitmap *pIcon = NULL,
  PegThing *Owner = NULL)

The first constructor creates a PegMLMessageWindow object at a specific location within a rectangle specified by parameter Rect. The rectangle defines the mReal position of the window. Use this constructor if you plan to add additional decorations to the message window.

If the message text will not fit within the rectangle specified by parameter Rect, the window will be increased in height until the text will fit. The top left position of the window and the window width will not be altered.

The second constructor creates a PegMLMessageWindow object centered in the parent's window. If the message window has no parent, the window will be centered on the screen. The window dimensions will be automatically calculated to accommodate the title bar, message text and all control buttons specified via style flags. This constructor form is most commonly used.

For both constructors, parameter Title defines the title string to be placed in a title bar at the top of the message window. The title bar will NOT include any system control buttons. If Title is NULL, the message window will have no title bar.

For both constructors, parameter pIcon identifies a bitmap image to be displayed to the left of the text message specified by parameter Message. If pIcon is NULL, no icon is displayed.

For both constructors, parameter Owner identifies the KwikPeg object (window or control) to which the message window is to send a PM_MWCOMPLETE message when the window is closed. If Owner is NULL, the completion notice will be sent to the message window's parent.

Parameter Owner is intended only for use when the message window is NOT executed modally. When the message window is being executed modally, the Execute() member function returns to its caller giving it the object ID of the button (object) that forced the message window to close.

 

Public Functions:

virtual void Draw(void)

The PegMLMessageWindow class overrides the Draw() function to display the bitmap icon, if one was provided, and the message text in the window client area.

virtual SIGNED Message(const PegMessage &Mesg)

The PegMLMessageWindow class overrides the Message() function to detect signals generated by the control buttons which close the message window.


Top of page


 Examples

The following example illustrates a PegMLMessageWindow object with OK, Retry and Cancel buttons.



The following code fragment was used to generate the message window shown above. The message window is created and executed modally.

void MyWindow::ModalMessage(void)
{
    PegMLMessageWindow *pWin =
        new PegMLMessageWindow("Example Message Window",
            "This is a multiline message window with a raised frame.",
            MW_OK | MW_CANCEL | MW_RETRY | FF_RAISED);

    Presentation()->Center(pWin);
    Presentation()->Add(pWin);
    pWin->Execute();
}



Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003