Standard message box dialog.
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 MessageBoxThen you should use either the MASkinG MessageBox or allegro_message() to communicate messages to the user.
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;
}
}
}
Alphabetic index Hierarchy of classes