Real Software Forums

A MsgBox Sort of Pause
Page 1 of 1

Author:  barrytraver [ Mon Jun 08, 2009 8:40 pm ]
Post subject:  A MsgBox Sort of Pause

I now know several ways to produce a pause of a definite length (a ticks loop, App.SleepCurrent Thread, and a Timer control). BUT now I need a different kind of "pause."

What I want is similar to a MsgBox saying "Click OK to proceed." In this case, the length of the pause is indefinite; the user determines the length. But I want to do it without using a MsgBox. How can that be done?

Right now I'm writing a game program where I want the user to have time to read what's on the screen; click, say, on a PushButton which says, "Press me to continue"; and then continue with the game when the PushButton is pushed.

I prefer NOT to use MsgBoxes when there is an alternative. Even the extra control you have through the MessageDialog doesn't quite do it. How else can I pause a program and have it resume when the user is ready to go on?

Barry Traver

Author:  timhare [ Mon Jun 08, 2009 10:40 pm ]
Post subject:  Re: A MsgBox Sort of Pause

What do you need that msgbox and MessageDialog don't give you? They are very flexible. If you really can't get what you want from those 2 classes, you can create a modal window that contains anything you want.


Author:  tcIgnatius [ Mon Jun 08, 2009 11:27 pm ]
Post subject:  Re: A MsgBox Sort of Pause

If the messageDialog doesn't work out for you, you could always try using a timer with a "state" variable. It's a bit more complex but would work well for games.
Here's an example I made: ... xample.rbp

Author:  barrytraver [ Tue Jun 09, 2009 12:49 am ]
Post subject:  Re: A MsgBox Sort of Pause

Both of the preceding solutions work fine! Somehow I remembered that MessageDialog allowed you to control the placement of the MsgBox, but forgot that it could be shown as modal. (I don't know know why, but I had the incorrect impression that only a window could be modal.) The example using the timer works fine also.

My game program ("NimRow," taken from one of Martin Gardner's "Mathematical Recreations" column in Scientific American, is almost finished, thanks to all the help I've gotten here. There are four options: (1) computer vs. computer, (2) computer vs. human, and (4) human vs. human. It really is finished, except for switching from the normal MsgBox to modal MessageDialog (or appropriate code using a Timer control. Oh yes, the program doesn't really require it, but I'll probably also be adding a choice to "Play through to the bitter end."

Even now, it's really complete (except for directions), and playing against the computer can be a rather humbling experience. I'm feeling pretty good, because -- although I had only worked on it in Windows -- I put the NimRow.rbp plus the two .bmp files needed for the sprites on an USB flash drive and brought that over to a computer running Linux (Fedora 10, to be specific). Using the Linux version of REALbasic on that computer, I loaded and run the Checkers.rbp program, and I was pleasantly surprised to find that also in Linux everything (including the sprites) seems to work as it's supposed to work! (It looked a bit different -- Windows apparently puts a MsgBox at the center of the screen, whereas Linux puts a MsgBox at the center of the program Window -- but it all worked.)

In a few days, I hope to post a note in the "Off Topic" forum as to how people can get a copy of the source code (free, of course) if they are interested. Thanks again for all the help!

Barry Traver

Author:  timhare [ Tue Jun 09, 2009 1:16 am ]
Post subject:  Re: A MsgBox Sort of Pause

barrytraver wrote:
I don't know know why, but I had the incorrect impression that only a window could be modal.

You are correct. Both MsgBox and MessageDialog are windows.


Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group