Creating an Extended Message and Input Box | CodeGuru

Creating an Extended Message and Input Box

Environment: VC6 CExtBox is a pure API class that provides different types of dynamically created, modal dialogs: Output: Message, splash, and progress boxes. Input: Combo, edit, check, radio, list, and “pathpicker” boxes. More by overriding some routines. Supported image resources are bmp, gif, jpg, ico, dib, emf, and wmf (splash boxes) or bmp, ico, ani, […]

Written By
CodeGuru Staff
CodeGuru Staff
Jun 9, 2003
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: VC6

CExtBox is a pure API class that provides different types of dynamically created, modal dialogs:

  • Output: Message, splash, and progress boxes.
  • Input: Combo, edit, check, radio, list, and “pathpicker” boxes.
  • More by overriding some routines.

Supported image resources are bmp, gif, jpg, ico, dib, emf, and wmf (splash boxes) or bmp, ico, ani, and avi (all other boxes). CExtBox supports all MB_xxx (MessageBox API) and the following flags:

BOX_BUTTON_RIGHT      // places buttons on the right side of
                      // the box
BOX_BUTTON_FLAT       // flat style
BOX_BUTTON_SUNKEN     // sunken style
BOX_BUTTON_STATIC     // simple border
BOX_BUTTON_DOUBLE     // double border
BOX_BUTTON_NONE       // no buttons if uiMillSecTimeout > 0
BOX_BUTTON_NONENOESC  // like BOX_BUTTON_NONE but pressing Esc
                      // won’t close the box
BOX_BUTTON_CONTEXT    // includes a question mark in the title bar
BOX_BUTTON_ALIGNR     // right-justifies the text in the button
                      // rectangle
BOX_BUTTON_ALIGNL     // left-justifies…
BOX_BUTTON_BELOW      // places one button beneath the other
BOX_BUTTON_MULTILINE  // wraps the button text to multiple lines
                      // (\n possible)
BOX_BUTTON_LAYER      // draws a sunken frame around the buttons
BOX_WIZARDSTYLE       // places buttons at the bottom and draws a
                      // line above
BOX_ICONFRAME         // draws a sunken frame around the icon
BOX_ANIMATE           // avi resource instead of an image
BOX_TEXT_BELOW        // places the text below the image
BOX_HICON             // nImageResID is an icon-handle
// —– valid flags for splash boxes:
BOX_BORDER_NONE           // splash box without a border
BOX_BORDER_THIN           // splash box with a thin border
BOX_BORDER_SLIDE          // slide-like splash border
BOX_BORDER_DOUBLESLIDE    // slide-like splash border
                          // (double strength)
// —– misc (rarely used) flags:
BOX_MISC_NOAVITRANS   // shows avi resource without transparency
BOX_MISC_NOCAPTION    // box without a caption
BOX_MISC_WACENTER     // centers the box in the work area
BOX_MISC_FORCETEXT    // show text (instead of system message)
                      // when system is low on memory

Technical Details

CExtBox installs a hook procedure, calls MessageBoxIndirect, and customizes the modal dialog. The implementation is thread-safe—I use Andrew Nosenko’s small CAuxThunk to give the hook and the subclassed window procedure access to the object pointer (“this”) by putting the value of the pointer in the ECX register, and simply jumping to the (non-static) member function’s code. So, CExtBox works without using static (or global) data such as static pointer, pointer maps, and so on.

Downloads


Download demo project – 108 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.