class MASKING_DLL_DECLSPEC MessageBox

Standard message box dialog.

Inheritance:

MessageBox - Window - Dialog - Widget - Rect


Public Fields

[more]Button button1
[more]Button button2
[more]Button button3
[more]Label line1
[more]Label line2
[more]Label line3
The three buttons and labels.

Public Methods

[more] MessageBox( const char* = "Message", const char* = "This is a message.", const char* = NULL, const char* = NULL, const char* = "OK", const char* = NULL, const char* = NULL)
The MessageBox constructor.
[more]virtual int Popup(Dialog* p, int x = MAXINT, int y = MAXINT)
[more]virtual int Popup(Dialog* p, const MAS::Point &pos)
Pops up the mesage box at the given position.

Protected Methods

[more]void CalculateGeometry()
Calculates the sizes and positions of all the labels and buttons according to the lengths of all the strings


Documentation

Standard message box dialog. A MessageBox is a simple dialog that can hold up to three lines of text and up to three buttons that all close it. It is primarily used for informing the user that a certain event has happened and for asking the user simple questions that can be answered with yes and no or something similar.

Note: the name MessageBox clashes with a define in the Win32 API. Micro$soft was stupid enough to call their message box function MessageBoxA and then they defined MessageBox as "#define MessageBox MessageBoxA" (most probably for backwards compatibility or something). If for some reason you need to use the Win32 API alongside MASkinG you have to undefine the Win32 MessageBox right after including the windows header:

      #include <winalleg.h>
      #undef MessageBox
Then you should use either the MASkinG MessageBox or allegro_message() to communicate messages to the user.
oButton button1

oButton button2

oButton button3

oLabel line1

oLabel line2

oLabel line3
The three buttons and labels. Note that all of these are public so you can access and change them as you wish.

ovoid CalculateGeometry()
Calculates the sizes and positions of all the labels and buttons according to the lengths of all the strings

o MessageBox( const char* = "Message", const char* = "This is a message.", const char* = NULL, const char* = NULL, const char* = "OK", const char* = NULL, const char* = NULL)
The MessageBox constructor. You can setup your message box in the constructor but you can change it at any time you want. The first parameter is the box's title, the next three are the three lines of text the box is to display and the last three are the labels of the three buttons. If you pass NULL instead of a valid string the relevant label or button will not be shown but a message box must have at least one label and at least on button.

ovirtual int Popup(Dialog* p, int x = MAXINT, int y = MAXINT)

ovirtual int Popup(Dialog* p, const MAS::Point &pos)
Pops up the mesage box at the given position. Returns the 1 based index of the button that was used to close the dialog. If the exit icon was used or the box was escaped 0 is returned.

Example:

      bool MainDialog::MsgClose() {
        if (HaveUnsavedData()) {
           MessageBox msg("Unsaved data", "Do you want to save your data before exiting?", NULL, NULL, "Yes", "No", "Cancel");
           switch (msg.Popup(this)) {
              case 1:
                 Save();

case 2: return true;

default: return false; }; } else { MessageBox msg("Really?", "Do you really want to exit?", NULL, NULL, "OK", "Cancel"); if (msg.Popup(this) == 1) { return true; } else { return false; } } }


This class has no child classes.

Alphabetic index Hierarchy of classes


Back to front page   |   page generated with DOC++