MessageBox With Timeout
int MsgBoxWithTimeout(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType, UINT uElapse, UINT uBlinkingTime);
The first 4 parameters are the same as in MessageBox. The message box will be closed in uElapse milliseconds unless there is any activity from the user. If the user does not close the message box, but either presses a key when it is in the foreground, or does some mouse action over its client or non-client area, the message box will wait for another uElapse milliseconds. uBlinkingTime milliseconds before closing, the message box caption will start blinking to attract user attention.
To be able to close the message box MsgBoxWithTimeout function spawns another thread. This new thread sleeps for a while to give the message box time to appear and then tries to find its window handle. To this end it uses EnumThreadWindows API function looking for the window with "#32770" class name. Then the function waits either for timeout, or the user to close the message box using WaitForSingleObject API. On timeout the function calls EndDialog API to close the message box.

Comments
Help me in Resolving this Error in WinXP Professional
Posted by Legacy on 10/10/2003 12:00amOriginally posted by: BKNAIDU
ReplyIts been a while...
Posted by Legacy on 07/08/2001 12:00amOriginally posted by: Tom
It has been a while since anyone said anything! Well, I donwloaded your program and found that if I clicked on the message box after it had loaded, the box did not go at all:
i.) Was this meant to happen?
ii.) Was the box supposed to close after 6 seconds of me clicking it?
ii.)Is this your definition of 'user interaction?'
Thanks it was good learning from it,
Tom
ReplyModeless message box
Posted by Legacy on 05/09/1999 12:00amOriginally posted by: Pabitra Dash
Hi,
Can I create a modeless message box?
Please help.
Regards,
ReplyPabitra
Great, but is it safe to use GWL_USERDATA?
Posted by Legacy on 04/01/1999 12:00amOriginally posted by: Mike Tsao
I was trying to do the exact same thing a few nights ago but was dismayed to find with Spy that message boxes appear to use in the GWL_USERDATA field (that's where I, like you, was planning to store the old winproc to subclass the dialog proc). I assum that the MessageBox() function was using it. But your code appears to blow away the current value without any ill effects.
I'm about to compile it and see if it works ok (which I'm sure it does), but have you figured out what's already in that field when it's passed to you?
ReplyWhat about logging?
Posted by Legacy on 03/31/1999 12:00amOriginally posted by: Brad Bruce
ReplyThank you. I got it.
Posted by Legacy on 03/26/1999 12:00amOriginally posted by: Masaaki Onishi
Hi.
Well, I appriciate for your help.
This is a first time for me to migrate MFC with C code.
Because I use application wizard, I got error message
about precompiled file - stdafx.h. But I just added it.
Now I am also working my individual interest -
change button caption - font style -add check box on Messagebox.
But I need to make some base class to make it general.
If you are interested in this, please update your code.
However, if you add more funtionality of your code,
TOMsgBox parameter will expand more?
Regards.
-Masaaki Onishi-
Reply
Oops, C code!. How do we add your code to our MFC project?
Posted by Legacy on 03/25/1999 12:00amOriginally posted by: Masaaki Onishi
Hi.
Your code is very interesting even though I'm not familiar
with C code.
However, how do we add your code to our MFC project?
I'v never made the combination of C code and MFC except
DLL.
I'm just lazy?
Thank you for your post.
-Masaaki Onishi-
Reply
Neat !
Posted by Legacy on 03/24/1999 12:00amOriginally posted by: Hans Wedemeyer
Thanks, it filled a gap, MFC and the API needed this..
Hans Wedemeyer
Reply