Use CListCtrl::SetItem to change the item's icon !m_ctlFileList.SetItem(l_iCurSelItem,0,LVIF_IMAGE,NULL,2,NULL,NULL,LVIF_PARAM);
CListCtrl::SetItem This method sets some or all attributes of a list view item.BOOL SetItem( const LVITEM* pItem );BOOL SetItem( int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem, int nImage, UINT nState, UINT nStateMask, LPARAM lParam ); Parameters pItem Specifies the address of an LVITEM structure that contains the new item attributes. The iItem and iSubItem members of a structure identify the item or subitem, and the mask member in a structure specifies which attributes to set. For more information on the mask member; see the Res section. nItem Specifies the index of the item whose attributes are to be set. nSubItem Specifies the index of the subitem whose attributes are to be set. nMask Specifies which attributes are to be set; see the Res section. lpszItem Specifies the address of a null-terminated string specifying the label of the item. nImage Specifies the index of the item’s image within the image list. nState Specifies values for states to be changed; see the Res section. nStateMask Specifies which states are to be changed; see the Res section. lParam Specifies a 32-bit application-specific value to be associated with the item. Return Value Nonzero if it is successful; otherwise, it is zero.Res The iItem and iSubItem members of the LVITEM structure and the nItem and nSubItem parameters identify the item and subitem whose attributes are to be set.The mask member of the LVITEM structure and the nMask parameter specify which item attributes are to be set: LVIF_TEXT The pszText member or the lpszItem parameter is the address of a null-terminated string; the cchTextMax member is ignored. LVIF_STATE The stateMask member or nStateMask parameter specifies which item states to change. The state member or nState parameter contains the values for those states. Example // Pointer to the list view control. CListCtrl* pmyListCtrl; // The pointer where the mouse was clicked. CPoint myPoint;// Select the item the user clicked on. UINT uFlags; int nItem = pmyListCtrl->HitTest(myPoint, &uFlags);if (uFlags & LVHT_ONITEMLABEL) { pmyListCtrl->SetItem(nItem, 0, LVIF_STATE, NULL, 0, LVIS_SELECTED, LVIS_SELECTED, 0); } 如下就可以了: m_ctlFileList.SetItem(l_iCurSelItem,0,LVIF_IMAGE,NULL,2,NULL,NULL,LVIF_PARAM);
CListCtrl Overview | Class Members | Hierarchy Chart | CListCtrl::GetItem
Sets some or all of a list view item's attributes.BOOL SetItem(
const LVITEM* pItem
);
BOOL SetItem(
int nItem,
int nSubItem,
UINT nMask,
LPCTSTR lpszItem,
int nImage,
UINT nState,
UINT nStateMask,
LPARAM lParam
);
BOOL SetItem(
int nItem,
int nSubItem,
UINT nMask,
LPCTSTR lpszItem,
int nImage,
UINT nState,
UINT nStateMask,
LPARAM lParam,
int nIndent
);
Parameters
pItem
Address of an LVITEM structure that contains the new item attributes, as described in the Platform SDK. The structure's iItem and iSubItem members identify the item or subitem, and the structure's mask member specifies which attributes to set. For more information on the mask member, see the Res.
nItem
Index of the item whose attributes are to be set.
nSubItem
Index of the subitem whose attributes are to be set.
nMask
Specifies which attributes are to be set (see the Res).
lpszItem
Address of a null-terminated string specifying the item's label.
nImage
Index of the item's image within the image list.
nState
Specifies values for states to be changed (see the Res).
nStateMask
Specifies which states are to be changed (see the Res).
lParam
A 32-bit application-specific value to be associated with the item.
nIndent
Width, in pixels, of the indentation. If nIndent is less than the system-defined minimum width, the new width is set to the system-defined minimum
Return Value
Nonzero if successful; otherwise zero.Res
The iItem and iSubItem members of the LVITEM structure and the nItem and nSubItem parameters identify the item and subitem whose attributes are to be set.The mask member of the LVITEM structure and the nMask parameter specify which item attributes are to be set: LVIF_TEXT The pszText member or the lpszItem parameter is the address of a null-terminated string; the cchTextMax member is ignored.
LVIF_STATE The stateMask member or nStateMask parameter specifies which item states to change and the state member or nState parameter contains the values for those states.
Example
See the example for CListCtrl::HitTest.See Also
CListCtrl Overview | Class Members | Hierarchy Chart | CListCtrl::GetItem--------------------------------------------------------------------------------Send feedback to Microsoft© 2001 Microsoft Corporation. All rights reserved.
m_ctlFileList.SetItem(l_iCurSelItem,0,LVIF_STATE,NULL,2,NULL,NULL,NULL);
不行呀.请问各个参数应该怎么填?谢谢!
This method sets some or all attributes of a list view item.BOOL SetItem(
const LVITEM* pItem );BOOL SetItem(
int nItem,
int nSubItem,
UINT nMask,
LPCTSTR lpszItem,
int nImage,
UINT nState,
UINT nStateMask,
LPARAM lParam );
Parameters
pItem
Specifies the address of an LVITEM structure that contains the new item attributes. The iItem and iSubItem members of a structure identify the item or subitem, and the mask member in a structure specifies which attributes to set. For more information on the mask member; see the Res section.
nItem
Specifies the index of the item whose attributes are to be set.
nSubItem
Specifies the index of the subitem whose attributes are to be set.
nMask
Specifies which attributes are to be set; see the Res section.
lpszItem
Specifies the address of a null-terminated string specifying the label of the item.
nImage
Specifies the index of the item’s image within the image list.
nState
Specifies values for states to be changed; see the Res section.
nStateMask
Specifies which states are to be changed; see the Res section.
lParam
Specifies a 32-bit application-specific value to be associated with the item.
Return Value
Nonzero if it is successful; otherwise, it is zero.Res
The iItem and iSubItem members of the LVITEM structure and the nItem and nSubItem parameters identify the item and subitem whose attributes are to be set.The mask member of the LVITEM structure and the nMask parameter specify which item attributes are to be set: LVIF_TEXT The pszText member or the lpszItem parameter is the address of a null-terminated string; the cchTextMax member is ignored.
LVIF_STATE The stateMask member or nStateMask parameter specifies which item states to change. The state member or nState parameter contains the values for those states.
Example
// Pointer to the list view control.
CListCtrl* pmyListCtrl;
// The pointer where the mouse was clicked.
CPoint myPoint;// Select the item the user clicked on.
UINT uFlags;
int nItem = pmyListCtrl->HitTest(myPoint, &uFlags);if (uFlags & LVHT_ONITEMLABEL)
{
pmyListCtrl->SetItem(nItem, 0, LVIF_STATE, NULL, 0, LVIS_SELECTED,
LVIS_SELECTED, 0);
}
如下就可以了:
m_ctlFileList.SetItem(l_iCurSelItem,0,LVIF_IMAGE,NULL,2,NULL,NULL,LVIF_PARAM);