打开MSDN查打CListCtrl的InsertItem函数,结果如下:
int InsertItem(
const LVITEM* pItem
);
int InsertItem(
int nItem,
LPCTSTR lpszItem
);
int InsertItem(
int nItem,
LPCTSTR lpszItem,
int nImage
);
......这里是对参数的解释,下面的例子
Example
// The pointer to my list view control.
extern CListCtrl* pmyListCtrl;CString strText;
int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount();// Insert 10 items in the list view control.
for (int i=0;i < 10;i++)
{
strText.Format(TEXT("item %d"), i); // Insert the item, select every other item.
pmyListCtrl->InsertItem(
LVIF_TEXT|LVIF_STATE, i, strText,
(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
0, 0); // Initialize the text of the subitems.
for (int j=1;j < nColumnCount;j++)
{
strText.Format(TEXT("sub-item %d %d"), i, j);
pmyListCtrl->SetItemText(i, j, strText);
}
}
请看上面的InsertItem函数,大家对这种写文档的方法有没有意见?
int InsertItem(
const LVITEM* pItem
);
int InsertItem(
int nItem,
LPCTSTR lpszItem
);
int InsertItem(
int nItem,
LPCTSTR lpszItem,
int nImage
);
......这里是对参数的解释,下面的例子
Example
// The pointer to my list view control.
extern CListCtrl* pmyListCtrl;CString strText;
int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount();// Insert 10 items in the list view control.
for (int i=0;i < 10;i++)
{
strText.Format(TEXT("item %d"), i); // Insert the item, select every other item.
pmyListCtrl->InsertItem(
LVIF_TEXT|LVIF_STATE, i, strText,
(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
0, 0); // Initialize the text of the subitems.
for (int j=1;j < nColumnCount;j++)
{
strText.Format(TEXT("sub-item %d %d"), i, j);
pmyListCtrl->SetItemText(i, j, strText);
}
}
请看上面的InsertItem函数,大家对这种写文档的方法有没有意见?
解决方案 »
- 求助,帮忙解释一下这个用法
- EnumChildWindows问题和大家讨论,都进来看啊,标题长。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
- VC2008中GetMenu()怎么使用
- 问下视图切换的问题
- 关于设备描述表的问题
- 问一个关于MFC SDI 分屏后 mainframe 刷新的问题
- 急急急急 老大们 有CRichEditCtrl使用方法的源码吗 谢谢
- 微软_编程精粹 作者姓名 Microsoft 打包下载
- 这种情况怎么来设计软件的结构?请高手们过来看看……
- Maxthon浏览器COM插件开发求助
- 把内存中一段读入由char *p指向的一段缓存,想要从中搜索数据,但数据类型不定,该怎样做?
- 在线等待:为什么MFC程序在退出的时候不调用CWinApp::ExitInstance()了?
int InsertItem( UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam );
这样没有问题了吧
CListCtrl::InsertItem
int InsertItem( const LVITEM* pItem );int InsertItem( int nItem, LPCTSTR lpszItem );int InsertItem( int nItem, LPCTSTR lpszItem, int nImage );int InsertItem( UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam );Return ValueThe index of the new item if successful or -1 otherwise.ParameterspItemPointer to anLVITEM structure that specifies the item’s attributes, as described in the Platform SDK. nItemIndex of the item to be inserted.lpszItem Address of a string containing the item’s label, or LPSTR_TEXTCALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.nImageIndex of the item’s image, or I_IMAGECALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.nMaskThe nMask parameter specifies which item attributes passed as parameters are valid. It can be one or more of the mask values described inLVITEM structure in the Platform SDK. The valid values can be combined with the bitwise OR operator.nStateIndicates the item's state, state image, and overlay image. See the Platform SDK topics LVITEM for more information andList View Item States for a list of valid flags.nStateMaskIndicates which bits of the state member will be retrieved or modified. See LVITEM in the Platform SDK for more information.nImageIndex of the item’s image within the image list.lParamA 32-bit application-specific value associated with the item. If this parameter is specified, you must set the nMask attribute LVIF_PARAM.ResInserts an item into the list view control.Example// The pointer to my list view control.
extern CListCtrl* pmyListCtrl;CString strText;
int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount();// Insert 10 items in the list view control.
for (int i=0;i < 10;i++)
{
strText.Format(TEXT("item %d"), i); // Insert the item, select every other item.
pmyListCtrl->InsertItem(
LVIF_TEXT|LVIF_STATE, i, strText,
(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
0, 0); // Initialize the text of the subitems.
for (int j=1;j < nColumnCount;j++)
{
strText.Format(TEXT("sub-item %d %d"), i, j);
pmyListCtrl->SetItemText(i, j, strText);
}
}
This method inserts an item into the list view control.int InsertItem(
const LVITEM* pItem );int InsertItem(
int nItem,
LPCTSTR lpszItem );int InsertItem(
int nItem,
LPCTSTR lpszItem,
int nImage );
Parameters
pItem
Specifies the pointer to an LVITEM structure that specifies the attributes of the item.
nItem
Specifies the index of the item to be inserted.
lpszItem
Specifies the address of a string containing the label of the item or LPSTR_TEXTCALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.
nImage
Specifies the index of an image for the item, or I_IMAGECALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.
nMask
Specifies which item attributes passed as parameters are valid. It can be one or more of the mask values. The valid values can be combined with the bitwise OR operator.
nState
Indicates the state of the item, state image, and overlay image.
nStateMask
Indicates which bits of the state member will be retrieved or modified. See LVITEM.
nImage
Specifies the index of an image for the item within the image list.
lParam
Specifies a 32-bit application-specific value associated with the item. If this parameter is specified, you must set the nMask attribute LVIF_PARAM.
Return Value
The index of the new item if it is successful; otherwise, it is –1.Example
// Pointer to the list view control.
CListCtrl* pmyListCtrl;CString strText;
int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount();// Insert 10 items in the list view control.
for (int i=0;i < 10;i++)
{
strText.Format(TEXT("item %d"), i); // Insert the item, then select every other item.
pmyListCtrl->InsertItem(
LVIF_TEXT|LVIF_STATE, i, strText,
(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
0, 0); // Initialize the text of the subitems.
for (int j=1;j < nColumnCount;j++)
{
strText.Format(TEXT("sub-item %d %d"), i, j);
pmyListCtrl->SetItemText(i, j, strText);
}
}Requirements
Windows CE versions: 1.0 and later
Header file: Declared in Afxcmn.h
Platform: H/PC Pro, Palm-size PC, Pocket PCSee Also
CListCtrl::DeleteItem, CListCtrl::DeleteAllItems我的是2003JAN1也是这样。郁闷
int InsertItem( const LVITEM* pItem );int InsertItem( int nItem, LPCTSTR lpszItem );int InsertItem( int nItem, LPCTSTR lpszItem, int nImage );int InsertItem( UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam );Return ValueThe index of the new item if successful or -1 otherwise.ParameterspItemPointer to anLVITEM structure that specifies the item’s attributes, as described in the Platform SDK. nItemIndex of the item to be inserted.lpszItem Address of a string containing the item’s label, or LPSTR_TEXTCALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.nImageIndex of the item’s image, or I_IMAGECALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.nMaskThe nMask parameter specifies which item attributes passed as parameters are valid. It can be one or more of the mask values described inLVITEM structure in the Platform SDK. The valid values can be combined with the bitwise OR operator.nStateIndicates the item's state, state image, and overlay image. See the Platform SDK topics LVITEM for more information andList View Item States for a list of valid flags.nStateMaskIndicates which bits of the state member will be retrieved or modified. See LVITEM in the Platform SDK for more information.nImageIndex of the item’s image within the image list.lParamA 32-bit application-specific value associated with the item. If this parameter is specified, you must set the nMask attribute LVIF_PARAM.ResInserts an item into the list view control.CListCtrl Overview | Class Members | Hierarchy ChartSee Also CListCtrl::DeleteItem, CListCtrl::DeleteAllItems
然后我打开MSDN6。0,没问题。
谢谢楼上的,收藏先!
pmyListCtrl->InsertItem
弹出来的窗口中并没有happyparrot(快乐鹦鹉)所说的那个版本的InsertItem函数,这一点我肯定!
是不是这个函数被放弃了,就像SetDialogBkColor()函数一样!