Show count down in a message box

Is there a way to show a count down in a MessageBox() in visual basic? I have a message box that will close in 6 seconds and I am wondering if there is an easy way to show the seconds counting down.
Thanks
Pat ClancyCEOAsked:
Who is Participating?
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
0
 
lion73Commented:
you can use form ..resize it... set alwaysontop property to true with timer to peroid you want to close it
0
 
Shaun VermaakConnect With a Mentor Technical Specialist/DeveloperCommented:
No, you have to create your own. You can easily use this as is or change it to VB.NET
[DllImport("user32.dll", EntryPoint="FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

[DllImport("user32.Dll")]
static extern int PostMessage(IntPtr hWnd, UInt32 msg, int wParam, int lParam);

private const UInt32 WM_CLOSE = 0x0010;

public void ShowAutoClosingMessageBox(string message, string caption)
{
    var timer = new System.Timers.Timer(6000) { AutoReset = false };
    timer.Elapsed += delegate
    {
        IntPtr hWnd = FindWindowByCaption(IntPtr.Zero, caption);
        if (hWnd.ToInt32() != 0) PostMessage(hWnd, WM_CLOSE, 0, 0);
    };
    timer.Enabled = true;
    MessageBox.Show(message, caption);
}

Open in new window

https://stackoverflow.com/questions/14522540/close-a-messagebox-after-several-seconds
0
 
Pat ClancyCEOAuthor Commented:
While a little more complicated than what I was looking for however these solutions will work once I modify my app.

Thank you
0
 
Pat ClancyCEOAuthor Commented:
Although a little more than I was asking for I can make it work.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.