Msgbox OK with timeout

Hi,

Is there a simple way to make a Msgbox (with only OK button) disappear after a number of (variale) seconds.

Thank you

Not with the default MessageBox/MessageDialog. Create a window, and use a timer.

You would have to use a timer like Ashot recommended above.

I imagined it was so, but I thought of a less complex.

Thank you.

[quote=171366:@Stefano Riva]I imagined it was so, but I thought of a less complex.

Thank you.[/quote]
What you are doing is event driven (asynchronous) so there is nothing that MSGBOX or a window can do at this point to close it self without a timer to manage. Using a timer in the basic form is easy as you drag a timer onto your project. Then enable it’s action with the proper close code you desire and ensure that you either set the timer to mode: Single (fire once at the time period) or mode: multiple (fire every time period) and of course set the time period.

I haven’t tried this, but I wonder if an external Timer could push the Action button in a MessageDialog?

Just a thought. If I were actually doing this in a project, I’d roll my own, as suggested.

I come from an experience of procedural programming with Autoit. In this language I had a Msgbox done this way: Msgbox (0, “Title”, “Text”, 5). The number 5 rappresents 5 seconds of timeout.

Stefano,

That makes sense as the command syntax from Autoit, however a message dialog in premise is to allow a User to press a button at their leisure (promoting user interaction with your software). Applying programatic actions to substitute the user seems counter intuitive a bit to me. Perhaps this isn’t a proper control that you may be needing?

What I wanted to do was just to save the data in a sqlite record and write on the screen (“record saved correctly”), doing the message disappear after 2-3 seconds.

Then use your own window with a timer as suggested. Call it MsgBoxWithTimeout.

Nothing special about a timer, so don’t be afraid :wink:

I understand Stefano and I know others will offer how they handle this type of status to the user.

For example I have done the following techniques that may provide additional ideas.

  1. Use a Modal Dialog Window and use a timer to close it after your time period (similar to suggestions above)

  2. Let the user press OK when they have read the status (Dont rely on Automatically closing it)

  3. Use the “Tooltip” which may or may not work for you, but provides a auto fade in with message and auto fade out.
    http://documentation.xojo.com/index.php/ToolTip

  4. Have a dedicated small textual area that represents status updates throughout your entire app.

Thank you for the support, now I will try your suggestions.

With your own window you can also leave it on screen if the data did not get saved correctly. It would be pretty bad if saving does not work and the user never sees it as it was closed automatically.

If on a Mac, think about taking advantage of the OS’s notification manager.