Virtual Developer Workshop: Containerized Development with Docker

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


Download demo project - 108 Kb


  • New download link

    Posted by mgesing on 04/06/2004 07:58pm


  • more code and the most recent version

    Posted by Legacy on 07/22/2003 07:00am

    Originally posted by: marcus gesing

    The most recent version of my published code should always be available at the following link:

  • Nice

    Posted by Legacy on 01/27/2003 08:00am

    Originally posted by: gregbrady

    I like it ...thanks :-)

  • Bitmaps

    Posted by Legacy on 10/30/2002 08:00am

    Originally posted by: freaky_NL

    whow, you didn't create those ico's/bmp's with VS did you?

    Nice program otherwise, gonna look into it (need to learn how to program). Third box outta ten hung here tho'.

  • How to display a 48*48 icon?

    Posted by Legacy on 10/26/2002 07:00am

    Originally posted by: wuwuli

    Hi, could you please tell me what is the secret to display a 48*48 icon on dialogbox, I have try to find it in your codes but cannot. It seems that the default size of icon in MessageBox is always 32*32.

  • hello

    Posted by Legacy on 09/10/2002 07:00am

    Originally posted by: lygyanghl

    good work!
    better coding!

  • Posted by Legacy on 09/09/2002 07:00am

    Originally posted by: Raja

  • Great stuff. and lets ignore idiots

    Posted by Legacy on 09/09/2002 07:00am

    Originally posted by: Kim Novak

    First of all this is very nice stuff. Especially that author used plain WinApi, so not only MFC people can use it. I personally prefer Borland c++ builder, so all the stuff that uses MFC is haarder for me to use, cause I need to cut off the MFC part.

    Author thanks a lot, for handy stuff.

    What I do regret is that some idiot, yeah idiot wrote stupid comment about authors skills of writing code. He didnt give any specific comment aabout what bothered, instead he made fool of himself.

  • Thanks

    Posted by Legacy on 09/07/2002 07:00am

    Originally posted by: kalee


  • Nice, memory requirements

    Posted by Legacy on 09/07/2002 07:00am

    Originally posted by: Alok Govil

    One food for thought for designing code for message boxes is that people revert to message boxes when any other error happens in the code, thus code for messages boxes by itself should be very robust.

    As an example, if memory allocation fails, the next guy would throw a message box, but what would happen if the message box code also tries to allocate memory!

    I am not saying all this about this work, but just pointing out a consideration that can sometimes be important.

    Regards - Alok

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

Most Popular Programming Stories

More for Developers

RSS Feeds

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