vc.txt

来自「Property Listbox 属性列表框」· 文本 代码 · 共 55 行

TXT
55
字号
将 CPropertyList box 加入 dialog 的步骤: 
Add the files ProperyList.h and PropertyList.cpp to your project. 
Add a list box to the dialog in which you wish to place a property list box. 
Set the properties for the list box to: 
Selection: Single 
Owner Draw: Variable 
Check the 'Has Strings' box and Uncheck the 'Sort' box 
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. 
Include the file "PropertyList.h" in your dialog class. 
使用 the CPropertyList box 
建立一个 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|". 
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);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?