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: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds