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

  • 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 …

  • A modern mobile IT strategy is no longer an option, it is an absolute business necessity. Today's most productive employees are not tied to a desk, an office, or a location. They are mobile. And your company's IT strategy has to be ready to support them with easy, reliable, 24/7 access to the business information they need, from anywhere in the world, across a broad range of communication devices. Here's how some of the nation's most progressive corporations are meeting the many needs of their mobile workers …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds