Countdown Dialog DLL

Environment: [eg C/C++ W32, W95/98/2000,NT etc.]

Have you ever needed a messagebox style dialog to wait before allowing processing to continue and then disappear automatically? This DLL has a simple dialog box with a progress bar that does just that. You can enter the number of seconds, the default button, the caption and the prompt. It counts down with a progress bar then closes itself returning either IDOK or IDCANCEL. The user can also press the buttons to close the dialog before the timer does.

Features

  • Everything's in the DLL
  • Easy to call function
  • Small footprint (32K)
  • Specify prompt, caption, seconds to close, default button
  • Pure Win32 API (no MFC, COM or ActiveX)
  • Optionally closes with loss of focus
  • Includes source code, test container and Visual C++ 6.0 project files. A good example for learning about DLLs.

Here's the calling code to use the DLL in your application. You'll also need to create a project and link in the common controls library, (commct32.lib) and the multithreading library.
// just include CountdownDialog.lib into your
// project.  Add the include file at the top
// of your source code (see below) and it's
// ready to use.

// Close on inactive option means that the dialog
// will close when the focus leaves--like when the
// user task switches to another application.

#include "commctrl.h"
#include "CountdownDialog.h"

// In your WinMain function...

   InitCommonControls(); // use new common controls



// Somewhere else like a push button event

   int ret = CountdownDialog(
      hwnd,
      "Perform some task now?",
      "Sample Caption Message",
      20, /* seconds till close */
      IDCANCEL, /* default on close */
      false /* close with loss of focus */ 
   ); 
   if ( ret == IDOK )
      // take the red pill :-)
   else
      // take the blue pill :-(


//
//
// or dynamically...

#include "commctrl.h"
#include "CountdownDialog.h"

// In your WinMain function...

   InitCommonControls(); // use new common controls



// Somewhere else like a push button event

   HMODULE hwnd = LoadLibrary( "CountdownDialog.dll" );
   if ( hwnd == NULL )
   {
      MessageBox( NULL, "LoadLibrary Failed", "Error", MB_OK );
      return;
   }
   pfnCountdownDialog CDD = (pfnCountdownDialog) \
      GetProcAddress( hwnd,"CountdownDialog" );
   if ( CDD == NULL )
   {
      MessageBox( NULL, "GetProcAddress Failed", "Error", MB_OK );
      FreeLibraryAndExitThread( hwnd, 0 );
      return;
   }
   int ret = CDD( hwndParent, "Prompt", "Title", 
      2, IDCANCEL, FALSE );
   FreeLibrary(hwnd);

   switch (ret)
   {
   case IDOK:
      MessageBox( NULL, "IDOK", "Result", MB_OK );
      break;
   case IDCANCEL:
      MessageBox( NULL, "IDCANCEL", "Result", MB_OK );
      break;
   }

Permissions: you can freely distribute and use this code in your projects as long as my name is in the revision log. Also, feel free to modify them and republish if you like as long as my name is still the log.

Downloads

Download demo project - 174 Kb (approx.)
Download source - 4 Kb


Comments

  • Hello

    Posted by Legacy on 10/23/2001 12:00am

    Originally posted by: Mamoon.ur.Rashed

    Hello,
    This is very good site, I like it very much.
    By.

    Reply
  • Is it possible to modify it to be non blocking???

    Posted by Legacy on 10/22/2001 12:00am

    Originally posted by: Amit Gefen

    I used that code as a non-dll in my project.
    I wonder if it possible to use it in a way like
    a flash window that is open for n-sec. and in that
    time the i disable the menu, do some GUI slow operation,
    hardware detecting &initializations, etc. Like on Win
    startup.
    In that exampple given here the GUI thread is blocked
    until the dialog finish the count ot until the user
    click ok/cancel.

    Reply
  • How to create/use a dialog with WS_EX_CONTEXTHELP style

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

    Originally posted by: vthieuanh

    Dear developers,
    Pls tell me asap how to create a dialog which have WS_EX_CONTEXTHELP style. if possible , pls give me a demo and source code?
    Thanks in advance.

    Reply
  • similar approach using only Win32-MessageBox-function

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

    Originally posted by: Markus loibl

    see
    
    http://www.codeproject.com/dialog/msgboxdemo.asp

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

Top White Papers and Webcasts

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Live Event Date: December 18, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this upcoming webcast …

Most Popular Programming Stories

More for Developers

RSS Feeds