A Property List Control

 Download Source Code and Example (45k)

Special note:Thanks goes to Keith Rule for the CMemDC class which
is used in the code.

In some of the applications I have developed, there has been a need
for user creatable options and for the integration of new object
types into an application without changing the application code. This
presents a problem when the new objects do not share all of the
properties of the previous objects. Visual Basic, MS Access and many
other applictions handle this problem through a property list type
interface (as shown above.)

I looked for a control to do this, but did not find one that I thought
was all that great. So, I wrote my own. This is the result.

This control is a CWnd derived class. It’s public interface is
similar to the CListCtrl and other MFC control classes. Functions
are provided for adding items, removing items and accessing the
settings for items.

I think it should be fairly easy to implement into other projects
without too much work. I have put together the sample application
to demonstrate how to use it.

How it works:

The CFPSPropertyList class contains a list of CFPSPropertyListItems.
These items implement the actual item draw/selection functionality.
Items are drawn Top Down and Scroll support is provided.

The CFPSPropertyListItem class implements functions for the
properties listed below. A message (FPS_PROPLIST_ITEM_CHANGED)
is sent to the parent window whenever a property item changes
the wParam member contains the item ID.

Edit Boxes/Combo Boxes are only created when needed and are
destroyed as soon as is reasonble. Text (and colors) are drawn
using standard CDC functions (not throught CEdit, CComboBox
classes)

When the user sizes the window, the contents are automatically
resized in the same way that VB does.

Property item types supported:

  • Text (Edit Box)
  • Combo (Combo Box)
  • Numbers – Long and Integer (Edit Box)
  • Font (CFontDialog)
  • Color (CColorDialog)
  • File (CFileDialog)
  • BOOLEAN (Toggle)

How to use the control:

  1. Allocate a CFPSPropertyList object
  2. Call one of the 2 ::Create functions for the class
  3. Add items to the list using the AddItem functions (3 Versions provided)
  4. ShowWindow(TRUE);

How to set item values:

Several SetItemValue functions are provided for setting the values for
individual property list items.

How to get item values:

Several GetItemValue functions are provided for retrieving values from
individual property list items.

Additional Control:

Individual CFPSPropertyListItem entries can be accessed through
MFC style list functions. These are

  • GetFirstItemPosition
  • GetNextItem
  • GetItemCount

Things to Improve:

If new property types are required, they can either be added
to the CFPSPropertyListItem class or a class can be derived
from CFPSPropertyListItem to implement new features.

Known Issues:

The scroll bar THUMB positioning mechanism is not implemented.

Last updated: 26 July 1998

More by Author

Must Read