打开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函数,大家对这种写文档的方法有没有意见?

解决方案 »

  1.   

    我说,你的MSDN哪个版本的?好像还漏了一个重载函数吧?
    int InsertItem( UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam );
    这样没有问题了吧
      

  2.   

    我的MSDN是这样的:
    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);
       }
    }
      

  3.   

    我的msdn跟happyparrot(快乐鹦鹉) 的一样,楼主你的msdn有问题吧
      

  4.   

    CListCtrl::InsertItem
    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也是这样。郁闷
      

  5.   

    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.CListCtrl Overview |  Class Members |  Hierarchy ChartSee Also   CListCtrl::DeleteItem, CListCtrl::DeleteAllItems
    然后我打开MSDN6。0,没问题。
      

  6.   

    我用的是MSDN2003,是现在最新版的.net2003自带的!居然会有个这么低级的漏洞!无语,
    谢谢楼上的,收藏先!
      

  7.   

    但我在VC++.net中这样打:
    pmyListCtrl->InsertItem
    弹出来的窗口中并没有happyparrot(快乐鹦鹉)所说的那个版本的InsertItem函数,这一点我肯定!
    是不是这个函数被放弃了,就像SetDialogBkColor()函数一样!