Property Listbox 属性列表框


日期: 2000-06-12 14:00 | 联系我
关注我: Telegram, Twitter

本程序用 MFC 实现 属性列表框(Property Listbox), 就象 VB 的 IDE 环境一样.用户可以在Property Listbox中包含 edit box, a combo box, an RBG color value, a font name, or a file name

  • 运行环境:Visual C++ 6 SP4

  • 作者:Noel Ramathal
  • 下载地址: 点此下载源代码及演示程序 | 下载地址2

  • 将 CPropertyList box 加入 dialog 的步骤:
    1. Add the files ProperyList.h and PropertyList.cpp to your project.
    2. Add a list box to the dialog in which you wish to place a property list box.
    3. Set the properties for the list box to:
      • Selection: Single
      • Owner Draw: Variable
      • Check the 'Has Strings' box and Uncheck the 'Sort' box
    4. Using the ClassWizard add a CPropertyList member variable for the list box. If you don't see a choice called CPropertyList, then select CListBox instead, and then manually edit the dialog class and set the variable to type CPropertyList.
    5. Include the file "PropertyList.h" in your dialog class.
  • 使用 the CPropertyList box
    1. 建立一个 CPropertyItem object, constructor 如下:

      CPropertyItem(CString propName, CString curValue, int nItemType, CString cmbItems)

      参数说明:

      • propName is a name for the property and is displayed in the first column
      • curValue is the initial value for the property
      • nItemType is either
        • PIT_COMBO (combo box control)
        • PIT_EDIT (edit box control)
        • PIT_COLOR (color chooser)
        • PIT_FONT (font selector)
        • PIT_FILE (file chooser)
      • cmbItems are the combo items if nItemType is set to PIT_COMBO, e.g., "TRUE|FALSE|".
    2. Add the CPropertyItem object to the CPropertyList box using the AddPropItem method:
      int AddPropItem(CPropertyItem* pItem);
      

    示例代码

    The following lines add a property of each type to a CPropertyList box (m_propList).

    //Add an edit box for a property called 'ToolTip Text'
    CPropertyItem* propItem1 =
     new CPropertyItem("ToolTip Text","",PIT_EDIT,"");
    m_propList.AddPropItem(propItem1);
    
    //Add a combo box with the choices 'true' and 'false'
    //for a property called 'Enabled'
    CPropertyItem* propItem2 =
     new CPropertyItem("Enabled","true",PIT_COMBO,"true|false|");
    m_propList.AddPropItem(propItem2);
    
    //Add a color chooser for a property called 'Back. Color'
    CPropertyItem* propItem3 =
     new CPropertyItem("Back. Color","",PIT_COLOR,"");
    m_propList.AddPropItem(propItem3);
    
    //Add a file chooser for a property called 'File Name'
    CPropertyItem* propItem4 =
     new CPropertyItem("File Name","",PIT_FILE,"");
    m_propList.AddPropItem(propItem4);
    
    //Add a font chooser for a property called 'Font'
    CPropertyItem* propItem5 = new CPropertyItem("Font","",PIT_FONT,"");
    m_propList.AddPropItem(propItem5);
    


 文章评论

第 1 楼  发表于 2009-07-20 18:59 | 刘洪 的所有评论
偶像,有机会教教我哦

第 2 楼  发表于 2010-04-16 15:44 | gao mountain 的所有评论
介绍的非常详细.对VC用户帮助很大啊~

第 3 楼  发表于 2011-11-19 16:26 | 逆为仙 的所有评论
多谢了,长见识了

第 4 楼  发表于 2011-12-24 10:33 | 大牛 的所有评论
学习就是要看到这样的文章!
比较的精辟。

共有评论 4 条, 显示 4 条。

当前页面是本站的 百度 MIP 版本。
欲查看完整版本和发表评论请点击:完整版 »

 

程序员小辉 建站于 1997
Copyright © XiaoHui.com; 保留所有权利。