listcontrol的中只能高亮选中第一列,如何高亮选中其他列
listcontrol的中只能高亮选中第一列,如何高亮选中其他列,另外还有一问,如何使得第一列也不高亮选中,请高手回答,3x。
[解决办法]
ListControl有个风格,叫做LVS_EX_FULLROWSELECT
你基本可以结贴了。
[解决办法]
可以试试:
m_List.SetSelectionMark(nItemIdx); // nItemIdx为高亮显示的行号;
m_List.SetFocus();
m_List.EnsureVisible( nItemIdx, FALSE );
m_List.SetItemState( nItemIdx, LVIS_SELECTED
[解决办法]
LVIS_FOCUSED, LVIS_SELECTED
[解决办法]
LVIS_FOCUSED );
void CColorCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
//draw each item.set txt color,bkcolor....
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
// Take the default processing unless we set this to something else below.
*pResult = CDRF_DODEFAULT;
// First thing - check the draw stage. If it's the control's prepaint
// stage, then tell Windows we want messages for every item.
if (pLVCD->nmcd.dwDrawStage == CDDS_PREPAINT)
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if (pLVCD->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
{
// This is the notification message for an item. We'll request
// notifications before each subitem's prepaint stage.
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if (pLVCD->nmcd.dwDrawStage == (CDDS_ITEMPREPAINT
[解决办法]
CDDS_SUBITEM))
{
// This is the prepaint stage for a subitem. Here's where we set the
// item's text and background colors. Our return value will tell
// Windows to draw the subitem itself, but it will use the new colors
// we set here.
int nItem = static_cast<int> (pLVCD->nmcd.dwItemSpec);
int nSubItem = pLVCD->iSubItem;
ItemData *pXLCD = (ItemData *) pLVCD->nmcd.lItemlParam;
ASSERT(pXLCD);
COLORREF crText = crWindowText;
COLORREF crBkgnd = crWindow;
if (pXLCD)
{
crText = (pXLCD->crText)[nSubItem];
crBkgnd = (pXLCD->crBak)[nSubItem];
}
// store the colors back in the NMLVCUSTOMDRAW struct
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
CRect rect;
GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, rect);
if (GetItemState(nItem, LVIS_SELECTED))
DrawText(nItem, nSubItem, pDC, crHighLightText, crHighLight , rect);
else
DrawText(nItem, nSubItem, pDC, crText, crBkgnd, rect);
*pResult = CDRF_SKIPDEFAULT;// We've painted everything.
}
}