[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


how to show a message box then close it automatically

Posted on 2010-01-04
Medium Priority
Last Modified: 2012-05-08
How can i show then close a messagebox without using the OK button?
Question by:cmdolcet
LVL 12

Expert Comment

ID: 26177310
Just as an alternative, you could design your own form and have it pop up with your message...make it look however you want it too...
LVL 61

Expert Comment

ID: 26177353
as suggested above, create a form with a label
add a timer, on timer event put me.close

create a function like showMessage(msg as string, t as integer)

this function will create the form, set the label to msg, activate the timer set the interval to t*1000

Accepted Solution

VipulKadia earned 500 total points
ID: 26177407
Use following line :
        CreateObject("WScript.Shell").Popup("Place message here", 3, "Message Title")

3 indicates the number of seconds of visibility of a message. After 3 seconds, message will be disappear.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 11

Expert Comment

ID: 26177453
I creating a form and show as suggested by rgn2121, is the best possible way.
LVL 39

Expert Comment

ID: 26177518
if your OS is windows XP or over you can use API's from user32.dll.

here is a class developed in c# based on these API calls.
Get the .CS file create a dll file and reference it in your application and call the MessageBoxEx.Show method.


Expert Comment

ID: 26177945
You may do the same as follows, enumerate the windows after you call the messagebox function something like

//first display your messagebox with some title that i name WindowTitle
EnumThreadWindows(GetCurrentThreadId(), EnumThreadWndProc, (LPARAM)WindowTitle);
The EnumThreadWindows is defined in below code window.

Hope it helps :)

// Define EnumThreadWndProc()
BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM lParam)
char WndName[50]; //to hold the title of message box, assuming title is withing 50 characters.
char* Title = (char*)lParam; 
// Get the title name of the messagebox window 
GetWindowText(hwnd, WndName, 50); 
// Find the message box dynamically within the code
if(strcmp(WndName, Title) == 0)
// Do whatever you want to the MessageBox
 //got the messagebox, now sleep for the time you like
 Sleep(1000); //1 sec sleep
//Now close the message box
 PostMessage(hwnd, WM_CLOSE, 0, 0); 
// Return FALSE to end search further.
return FALSE;
// Should return TRUE to continue
return TRUE;

Open in new window

LVL 70

Expert Comment

by:Éric Moreau
ID: 26179033

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question