Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(C++) MessageBox for Linux like in MS Windows

Tags:

People also ask

What do you mean by MessageBox explain all its possible display with example?

A message box is a prefabricated modal dialog box that displays a text message to a user. You show a message box by calling the static Show method of the MessageBox class. The text message that is displayed is the string argument that you pass to Show.

Why message box is used in C++?

Borland C++ Builder: Message Boxes. A message box is a relatively small dialog box used to display a message and provide one or more buttons. Here is an example of a message box: A message box is used to provide information to the user or to request a decision (from the user).

What does MessageBox return?

Return valueIf a message box has a Cancel button, the function returns the IDCANCEL value if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing ESC will no effect - unless an MB_OK button is present.

How do I make a message box in C++?

The MessageBox function in Windows is one of the easiest to master, and it simply generates a popup box from the main application window. Simply use the following syntax: MessageBox(NULL, L"Text", L"Title", MB_ICONINFORMATION);


I need to implement a simple graphical message box for a Linux (SDL) application similar to the Windows MessageBox in C++ (gcc/g++ 4.4.0). All it needs to do is to display a caption, a message and an ok or close button and to return to the calling function when that button is clicked.

SDL just uses X(11) to open a window for (OpenGL) rendering.

I have looked through a similar thread regarding a GTK implementation, but that implementation doesn't seem to work properly.

I have also tried wxWidgets' wxMessageBox function, but compiling the headers makes the compiler throw error messages about syntax errors in include/c++/4.4.0/bits/stl_algobase.h (gcc 4.4.0 32 bits on openSuSE 11.1 32 bits). Using wxWidgets also means having to link a ton of libraries, adding STL to my app (Which it doesn't need otherwise) and who knows what else, so I do not want to use wxWidgets.

X11/motif (openmotif) has what I need (XmCreate{Error|Warning|InfoDialog), but these need a parent widget (e.g. top level window) which I don't have and do not accept a NULL parameter for these.

So I am stumped right now. Is there a simple way to do what I want? Or at least a halfway simple/easy/straightforward one? If yes, which one (giving as many details as possible would be highly appreciated).