dcsimg

MessageBox With Timeout

WEBINAR:
On-Demand

Application Security Testing: An Integral Part of DevOps


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 ...

    • You must have javascript enabled in order to post comments.

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

    Top White Papers and Webcasts

    • Hybrid IT consists of both cloud and on-premises data center infrastructure. This book helps you understand both sides of the hybrid IT equation and how HPE can help your organization transform its IT operations and save time and money in the process. I delve into the worlds of security, economics, and operations to show you new ways to support your business workloads.

    • Today, Cloud First has become a major movement across the global business landscape. As cloud computing has become an imperative for global enterprises, Cloud First is key in building a long-term roadmap for cloud services by implementing higher application performance, higher scalability, and reduced spending on infrastructure. But how does a business go about developing a Cloud-First strategy that retains a maximum return on investment (ROI)? Read this white paper to discover solutions to hidden costs in the …

    Most Popular Programming Stories

    More for Developers

    RSS Feeds

    Thanks for your registration, follow us on our social networks to keep up-to-date
    ×
    We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.