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


Comments

  • New download link

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

    http://www.footwear-box.de/download/ExtLib.exe

    Reply
  • more code and the most recent version

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

    Originally posted by: marcus gesing

    The most recent version of my published code should always be available at the following link:
    http://home.arcor.de/footwear-box/various/coding/ExtLib.zip

    Reply
  • Nice

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

    Originally posted by: gregbrady

    I like it ...thanks :-)

    Reply
  • Bitmaps

    Posted by Legacy on 10/30/2002 12: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'.

    Reply
  • How to display a 48*48 icon?

    Posted by Legacy on 10/26/2002 12: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.
    thanks!!!

    Reply
  • hello

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

    Originally posted by: lygyanghl

    good work!
    better coding!

    Reply
  • Great stuff. and lets ignore idiots

    Posted by Legacy on 09/09/2002 12: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.

    Reply
  • Posted by Legacy on 09/09/2002 12:00am

    Originally posted by: Raja

    Reply
  • Thanks

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

    Originally posted by: kalee

    Thanks

    Reply
  • Nice, memory requirements

    Posted by Legacy on 09/07/2002 12: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

    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: October 29, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this eSeminar, Gene Kim will discuss these survey findings and will share woeful tales of artifact management gone wrong! Gene will also share examples of how …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds