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



Comments

  • One small correction...

    Posted by Legacy on 12/24/1998 12:00am

    Originally posted by: Warren Marshall


    If you add the line...

    m_pItemEditWindow->SetFocus();

    ...at the bottom of the "CFPSPropertyListItem::DisplayEditBox" function, you can make it so you only have to click once to edit a text box, instead of twice like you do now.

    Otherwise, this is a great control! Just what I was looking for. I was 10 minutes away from writing one of my own, and I thought "well, might as well check codeguru. Maybe someone has made something similar to what I want."

    Heh, no. Someone has made EXACTLY what I want. :)

    Thanks again!

    Warren.

    Reply
  • Property List and Property List Demo

    Posted by Legacy on 11/18/1998 12:00am

    Originally posted by: Vince Blasberg

    Subject: Property List and Property List Demo

    Love it!!

    "m_nPropList.Invalidate();" helped the scroll feature and an immediate update of SetItemValue(..);

    Needed to clear the list with "ItemInfo.ComboBoxList.RemoveAll();" before setting up another combo box type otherwise each subsequent combo will have more and more...

    Changed the Boolean types to the standard "True" and "False" and set them in an additional DblClick and pulled them out of the click event for more standard interaction.

    Love it!!

    Thanks as Usual
    Vince Blasberg
    Symon Communications

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

Top White Papers and Webcasts

  • The operational costs of managing an x86 base are taxing IT budgets, making it difficult to fund and staff new initiatives. Today's IT organization must seek efficiencies in its operations and shift to a more agile infrastructure that's flexible enough to adapt to future changes in the business. Read this Q & A session with Jed Scaramella, research manager for IDC's Enterprise Platforms and Data Center Trends, to learn how the integrated nature of the blade platform delivers critically needed efficiencies …

  • Today's competitive marketplace requires the organization to frequently release and deploy applications at the pace of user demands, with reduced cost, risk, and increased quality. This book defines the basics of application release and deployment, and provides best practices for implementation with resources for a deeper dive. Inside you will find: The business and technical drivers behind automated application release and deployment. Evaluation guides for application release and deployment solutions. …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds