比如要在第一列,第二列第四列各显示一个image及文本,
详细步骤。 第一列 第二列 第三列 第四列
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
详细步骤。 第一列 第二列 第三列 第四列
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
图 文本 图 文本 文本 图 文本
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = 0; // If this is the beginning of the control's paint cycle, request
// notifications for each item. if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
// This is the pre-paint stage for an item. We need to make another
// request to be notified during the post-paint stage. *pResult = CDRF_NOTIFYPOSTPAINT;
}
else if ( CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage )
{
// If this item is selected, re-draw the icon in its normal
// color (not blended with the highlight color).
LVITEM rItem;
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec ); // Get the image index and state of this item. Note that we need to
// check the selected state manually. The docs _say_ that the
// item's state is in pLVCD->nmcd.uItemState, but during my testing
// it was always equal to 0x0201, which doesn't make sense, since
// the max CDIS_ constant in commctrl.h is 0x0100. ZeroMemory ( &rItem, sizeof(LVITEM) );
rItem.mask = LVIF_IMAGE | LVIF_STATE;
rItem.iItem = nItem;
rItem.stateMask = LVIS_SELECTED;
m_list.GetItem ( &rItem ); // If this item is selected, redraw the icon with its normal colors. if ( rItem.state & LVIS_SELECTED )
{
CDC* pDC = CDC::FromHandle ( pLVCD->nmcd.hdc );
CRect rcIcon; // Get the rect that holds the item's icon.
m_list.GetItemRect ( nItem, &rcIcon, LVIR_ICON ); // Draw the icon.
m_imglist.Draw ( pDC, rItem.iImage, rcIcon.TopLeft(),
ILD_TRANSPARENT ); *pResult = CDRF_SKIPDEFAULT;
}
}
}
设了LVS_EX_SUBITEMIMAGE后如何加image, 请详细点.TO: okli(东方不BUG)
CListCtrlParentContianer::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = 0;
....
}
不懂。哪里来的,请解释一下,谢谢!
使用窗体和控件的信息交互过程,具体在msdn中有说明
假设你要设置第一行第二列为image
则:
LVITEM lvitem;
lvitem.mask = LVIF_IMAGE;
lvitem.iItem = 0;
lvitem.iSubItem = 1;
lvitem.iImage = 0; //0是你的imagelist里面的第一个image
VERIFY( m_wndList.SetItem( &lvitem ) );
三少爷的剑倒不错...