addMessageBox() question
addMessageBox() question
I found the addMessageBox() funtion is not blocked;
Codes like:
...
env->addMessageBox(L"MessageBox Test",L"Hello
IRR",true,EMBF_OK|EMBF_CANCEL);
int i;
i = i + 1;
...
When I call the addMessageBox funtion, it exit soon!
Can I running the "i = i + 1" until the messagebox closed?
Codes like:
...
env->addMessageBox(L"MessageBox Test",L"Hello
IRR",true,EMBF_OK|EMBF_CANCEL);
int i;
i = i + 1;
...
When I call the addMessageBox funtion, it exit soon!
Can I running the "i = i + 1" until the messagebox closed?
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
h++ wrote:But how can I send the event to main program!
Just check for the EGET_MESSAGEBOX_OK and/or EGET_MESSAGEBOX_CANCEL event.Sylence wrote:You will be informed about the message box being closed in the event receiver
Correct. It returns an IGUIWindow.h++ wrote:I found the addmessagebox() doesn`t return the button value of OK/CANCEL!
"Whoops..."
There is actually a way to get real blocking modal Messageboxes like you have them for example in MFC, but it's a little tricky.
Basically you have to code the same trick which MFC does use: You have to write your mainloop in such a way that it's called within a function which started the MessageBox. And that loop only quits once the MessageBox has been closed.
Basically you have to code the same trick which MFC does use: You have to write your mainloop in such a way that it's called within a function which started the MessageBox. And that loop only quits once the MessageBox has been closed.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
It is mean that I will write a class: it public to cguiwindow or others!then translate the button even?CuteAlien wrote:There is actually a way to get real blocking modal Messageboxes like you have them for example in MFC, but it's a little tricky.
Basically you have to code the same trick which MFC does use: You have to write your mainloop in such a way that it's called within a function which started the MessageBox. And that loop only quits once the MessageBox has been closed.
The way I did it was to have a RunModal function in my main application class as that class was the one doing the gameloop. RunModal had the dialog which should be run modal as parameter and in the loop it checked if the dialog was still visible (although checking for messagebox-events might also work in your case, I just needed more general functionality).
It might be a little tricky, so you should usually try to avoid doing that and in most cases you don't actually need it. Prefer working with the events and non-blocking.
It might be a little tricky, so you should usually try to avoid doing that and in most cases you don't actually need it. Prefer working with the events and non-blocking.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Yet!CuteAlien wrote:The way I did it was to have a RunModal function in my main application class as that class was the one doing the gameloop. RunModal had the dialog which should be run modal as parameter and in the loop it checked if the dialog was still visible (although checking for messagebox-events might also work in your case, I just needed more general functionality).
It might be a little tricky, so you should usually try to avoid doing that and in most cases you don't actually need it. Prefer working with the events and non-blocking.
I am creating a class with mainloop, and it doesn`t work like what I think!
It just likes what you say!I don`t know how to deal with avoid user to operate the main windows!
Can somebody tell me?
When you have a modal messgebox the user shouldn't be able to operate the mainwindow at the same time.
If that is what you meant...
If that is what you meant...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Oh!CuteAlien wrote:When you have a modal messgebox the user shouldn't be able to operate the mainwindow at the same time.
If that is what you meant...
I just want to do like MFC!
But I don`t know how to avoid user to operate the mainwindow when the messagebox window is showed!
And now! when the messagebow window is showed! I found I also can operate the mainwindow!
But I found it isn`t block!Sylence wrote:addMeesageBox() has a "modal" parameter. Set it to true and the user can't interact with the gui except closing the message box.
when the messagebox is showed! The next code also can run!
Now! I just want the next code will be runed until the messagebox was closed by user!And now I creat a class which isn`t avoid user to operate the mainwindow when the messagebox showed!
So,what shell I do!
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
C++ knows the concept of classes and methods, so there's no need to 'stop' the execution of your code. Just call the code after your eventreceiver got the close event.h++ wrote:I just want the next code will be runed until the messagebox was closed by user!
1. Create an EventReceiver which checks if the user closed the box
2. addTheBox
3. In your event receiver, when the close event arrives, call the other code
Easy, hu?
"Whoops..."
But when you obtain two or more messagebox but one just showed each time! And how to separate the event from the messagebox?randomMesh wrote:C++ knows the concept of classes and methods, so there's no need to 'stop' the execution of your code. Just call the code after your eventreceiver got the close event.h++ wrote:I just want the next code will be runed until the messagebox was closed by user!
1. Create an EventReceiver which checks if the user closed the box
2. addTheBox
3. In your event receiver, when the close event arrives, call the other code
Easy, hu?