Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox Question.

Status
Not open for further replies.

elmorro

Programmer
Jun 23, 2005
133
US
Hi all,
Is there a way to create a Message Box in VB6 that does not have any buttons and disappears after a specified time (i.e. 30 seconds) without any user interferance?

Thanks in advance for your help.
elmorro ;-)
 
Not using a MsgBox statement; I suggest to create a little Form possibly with a built-in timer to do what you require.
 
I wouldn't recommend such a thing generally, as it is contrary to Microsoft's UI specifications. For example, if the user wanted to get rid of the box before the 30 seconds were up, there would be no way to do that. That would annoy me, personally, and I suspect I'm not alone.

HTH

Bob
 
Bob,

Agreed. In practice it would be good to have a cancel Button which displayed the countdown in its Caption.
 
Hi elmorro,

I found a little program to manipulate the MsgBox some time ago, but lost all my Favourites due to a hard drive crash.

I searched again and found it here;


The original code was written by Bryan Stafford of New Vision Software®.

I've only tried the demo with three buttons to bring up message boxes with different changes, and they all work as described.

Also, the automatic closing box can be closed immediately with the OK button. I don't think it would be too difficult to adapt this code for your requirements.

I hope this helps. I would post the .zip file, but I'm not sure how to do it, or if it is allowed.

Best Regards,

Marcus
 
Wantok52,
Thanks for the link. I will definately look it up. I'll let you know if it's what I need.

elmorro :)
 
If you can live with at least one button on it and you have XP, then you'll be pleased to know there is a MessageBox on the system that can have a timeout set up on it:
Code:
[blue]
Option Explicit

Private Declare Function MessageBoxTimeOut Lib "user32" Alias "MessageBoxTimeoutA" (ByVal hWnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal uType As VbMsgBoxStyle, ByVal wLanguageId As Long, ByVal dwMilliseconds As Long) As Long

Private Sub Command1_Click()
    MessageBoxTimeOut 0&, "Example MessageBox", "I'll disappear soon ...", vbInformation + vbOKOnly, 0&, Text1.Text
End Sub[/blue]
 
For further reading you might also like to look at thread222-662729, which contains a timer-based and a hook-based technique for modifying Inputboxes and messageboxes that is a little simpler than the previous link (the examples from ca8msm and myself target an InputBox but can equally well be used for a messagebox)
 
Thanks strongm. I will use the textbox with the timeout.

elmorro :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top