MessageBox problem

Started by roccio, 24 June 2016, 12:00:18


Hello again,
I have a problem with the tgui::MessageBox.

I think the problem is with the VisualC++ compiler as it trys to replace MEssageBox with MessageBoxA as it is defined in the macro
#define MessageBox MessageBoxA

Is there a solution for this?


Ideally you would just not include TGUI and windows.h in the same files. But you can just add this after including windows.h:
Code (cpp) Select
#undef MessageBox

There isn't much that I could do to prevent this, this is exactly the reason why people should use namespaces and never put defines of common words in a header file.


Ok, this way it works. Another question:

is it possible to have the messagebox modal?

how to get the button pressed?

Sorry for so many questions, but I have not found an example of how to use this widget.


To prevent the things behind the messagebox to be used, you can create a Panel that fills the whole screen before you create the MessageBox. You can give the panel a transparent background color to make it look nice with something like "panel->getRenderer()->setBackgroundColor({0,0,0, 150});"

To get the pressed button you can connect to the ButtonPressed signal. You probably will also have to handle the Closed signal as well (if you connect to it then you have to remove the messagebox yourself).

The tutorials and examples are indeed still lacking, which probably won't improve much until the next tgui version.