MessageBox With Timeout

This is a simple class that displays a message box and automatically closes it after a specified amount of time.

This class has a very simple interface

  • Two public constructors
  • 
    CMessageBoxEx()
    CMessageBoxEx(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType, UINT uTimeOut, BOOL bShowTimeOut = TRUE)
    
  • Two public methods to execute Timed Out Message Box
    
    int DoMessageBox()
    int DoMessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType, UINT uTimeOut, BOOL bShowTimeOut = TRUE)
    
    The object creates a thread to check time elapsed. When timeout is reached, the thread posts WM_CLOSE message to the message box.


  • Comments

    • Messae Box with timeout - where is it?

      Posted by Baruch on 03/19/2010 12:00pm

      Can someone specify how to download the actual code or messagebox control?

      Reply
    • Messagebox with voice

      Posted by mayurnimbalkar on 08/06/2007 12:52am

      hi, i want to display not only messagebox but also want to make text of message audiable. regards, mayur

      Reply
    • Messagebox with voice

      Posted by mayurnimbalkar on 08/06/2007 12:49am

      hi, i want to not only display messagebox but also want to be listen the text of meesagebox on sound or in audio format. Is it possible? Regards, Mayur.

      Reply
    • Source code found (again)

      Posted by kotyczka on 05/11/2006 10:03am

      http://www.codeguru.com/code/legacy/misc/MessageBoxEx_src.zip

      Reply
    • Create CMessageBoxEx once, call often ...

      Posted by Legacy on 01/19/2001 12:00am

      Originally posted by: Lutz

      I tried to create a CMessageBoxEx object in MFC InitInstance() and delete in ExitInstance().
      
      First call was o.k., but in next calls the timer didn't run.
      Solution seems to be simple:
      In second constructor
      CMessageBoxEx::DoMessageBox(HWND hWnd,...)

      insert
      m_nResult = 0;

      before call TimedOutMessageBox().

      I also removed the first thread like suggested.
      Hope these changes work well in multithreaded applications.
      Nice class!

      Reply
    • New Fix : Use WM_CLOSE instead of WM_QUIT

      Posted by Legacy on 03/31/2000 12:00am

      Originally posted by: Martin-Pierre Frenette and by Alexandr Shcherbakov

      Here is a new fix for the class, which came from Alexandr after discussion between Alexandr and Me ( Martin-Pierre ) :

      Send the WM_CLOSE msg instead of WM_QUIT or WM_COMMAND|ID_OK

      Therefore, the line :

      PostMessage(FindWindow(NULL, pObject->m_szTimeOutCaption), WM_QUIT, 0, 0);

      becomes the line :

      PostMessage(FindWindow(NULL, pObject->m_szTimeOutCaption), WM_CLOSE, 0, 0);

      Reply
    • How do I allow multiple concurrent calls to MessageBoxEx?

      Posted by Legacy on 09/01/1999 12:00am

      Originally posted by: David

      I would like to allow my application to call this routine more than once, and it is possible that more than one messageboxes will be on the screen at the same time ...

      Any ideas on an elegant fix, or do I have to write something from scratch?

      Reply
    • A simpler way

      Posted by Legacy on 08/25/1999 12:00am

      Originally posted by: Navin Mishra

      I used a timer to close a modal dialog box.

      Reply
    • Where is the code?

      Posted by Legacy on 08/06/1999 12:00am

      Originally posted by: Colin Elligsen

      I only see four method definitions myself? Am I missing something?

      Reply
    • Where is the archive ?

      Posted by Legacy on 08/02/1999 12:00am

      Originally posted by: jbackdoor

      I said everything in the subject :)

      Bye

      Reply
    • Loading, Please Wait ...

    Leave a Comment
    • Your email address will not be published. All fields are required.

    Top White Papers and Webcasts

    • Entire organizations suffer when their networks can't keep up and new opportunities are put on hold. Waiting on service providers isn't good business. In these examples, learn how to simplify network management so that your organization can better manage costs, adapt quickly to business demands, and seize market opportunities when they arise.

    • The open source cloud computing project OpenStack has come a long way since NASA and Rackspace launched it in 2010. Backed by leading technology infrastructure providers including Cisco, Dell, EMC, HP, IBM, Intel, and VMware, OpenStack underpins significant workloads at an increasingly diverse set of organizations, including BWM, CERN, Comcast, eBay, and Wal-Mart. For CIOs engaged in broader programs to win, serve, and retain customers -- and refocus business technology (BT) spend -- a planned and pragmatic …

    Most Popular Programming Stories

    More for Developers

    RSS Feeds

    Thanks for your registration, follow us on our social networks to keep up-to-date