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

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • On-demand Event Event Date: October 29, 2014 It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this webcast, Gene Kim discusses these survey findings and shares woeful tales of artifact management gone wrong! Gene also shares examples of how high-performing DevOps …

Most Popular Programming Stories

More for Developers

RSS Feeds