
                      IEList32 - 12/23/94 by Mark Gamber

   By using the program or any included part, the user assumes full respon-
-sibility for it's use and may not hold the author liable for any loss or
damage. If unable to accept this condition, the program and all included parts
must be destroyed immediately. The program and all included parts are public
domain, and may be freely distributed. The example was built using Microsoft C
targetting Win32.


   This is an example of a custom control which creates and controls a listbox
for the purpose of allowing the listbox text to be changed "inline".


   The custom control is initialized with a call to InitializeIEList() which
registers the classname. The control is created using CreateWindow() and may
use an optional creation string (caption text), normally unused when creating
a listbox, to fill the listbox during WM_CREATE of the custom control. If used,
the string passed is one string consisting of a number of smaller strings, each
up to 128 characters in length, separated by a '\n'. For example, to add two
items, you might call CreateWindow() like this:

      CreateWindow( "IELIST32", "Item #1\nItem #2", ... )

The entire string is NULL terminated (\0). Items may be added and removed using
the various LB_ messages as usual once the control is created.


   The listbox is created as ownerdraw. Each item is expanded slightly since an
edit control is larger than a listbox item. The text, however, tends to cling
to the top which causes it to "jump" when the edit is created in the same spot.
To prevent this, the custom control handles drawing the listbox text using
DrawText( ...,  DT_VCENTER ). The custom control (IELIST32) also handles
passing messages from it's parent to the child listbox and vice versa so the
controlling application deals with what seems to be a more or less normal
listbox. The exception is IEL_EDITITEM which is passed as the wParam parameter
of a WM_COMMAND message to edit the currently selected item programmatically.
For example, to edit the second visible item, you would use:

      SendMessage( hCtrl, LB_SETCURSET, 1, 0 );
      SendMessage( hCtrl, WM_COMMAND, IEL_EDITITEM, 0 );

Where the first message selects the item and the second causes the control to
enter "edit mode". To allow this message passing, the listbox is subclassed.


   When the edit command is sent or an item is double-clicked, the control goes
into "edit mode", creating an edit control with the listbox item text, an OK
and a Cancel button. The items are created 1 pixel above the position of the
listbox and 2 pixels larger, allowing decent vertical centering of the text in
the edit control. Each button is created as side as the edit is high, creating
two squares with the edit occupying the rest of the item area. When the control
is resized, the editing controls are destroyed. In addition, they may be
destroyed by selecting another listbox item or using the scrollbar. The
scrollbar restriction, however, is not required while the others are. If the
controls are not destroyed on using the scrollbar, the listbox automatically
handles scrolling the controls as they are created as child windows to the
listbox. The edit control is also subclassed to allow trapping the Enter and
Cancel keys to end the edit mode with or without change.
   Note that in this example, when an item is changed, the item data used to
color the text is also changed. This is optional and the entire LB_SETITEMDATA
and LB_GETITEMDATA scheme can be replaced with something else or nothing at all.


   The control is easily modified as it's just a collection of standard Windows
controls tied together by a "middle man" window. To keep it from getting any
more complex than it already is, a number of nice features were omitted from
the program such as change notification, edit mode enter and exit notification
and so on. These are up to you to implement.


