vc++中CListCtrl控件中怎么样才能选中某一行的某一列?
在vc++中,要么就只能点第一列的元素来选中,要么就是选中一整行,,怎么样才能选中某一行的某一列的具体单个元素阿...
在vc++中,要么就 只能点第一列的元素来选中,要么就是选中一整行,,怎么样才能选中某一行的某一列的具体单个元素阿
展开
1个回答
展开全部
我给你列出来
//////////////////////////////////////////////////////////////////////////
// 增加背景色彩
void CXXSortListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYSUBITEMDRAW; // ask for subitem notifications.
break;
case CDDS_ITEMPREPAINT: // ask for subitem notifications.
*pResult = CDRF_NOTIFYSUBITEMDRAW;
if(GetExtendedStyle() & LVS_EX_CHECKBOXES)// if we have a checkbox style,
{ // forget about subitem notifications.
*pResult = CDRF_DODEFAULT;
int iRow = lplvcd->nmcd.dwItemSpec;
if((iRow & 1))// && (iCol & 1)) // 单行
{
lplvcd->clrTextBk =m_clrLine; // RGB(255, 0, 0);
lplvcd->clrText =m_clrText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
else // 双行
{
lplvcd->clrTextBk =m_clrTwoLine; // RGB(255, 0, 0);
lplvcd->clrText =m_clrText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
// 注意......... :)
// 这里就是你要更改的地方...
if(GetCheck(iRow)) // highlight checked rows
{
//lplvcd->clrTextBk =m_clrChkText; // RGB(255, 0, 0);
lplvcd->clrText =m_clrChkText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
}
break;
case CDDS_ITEMPREPAINT|CDDS_SUBITEM: // recd when CDRF_NOTIFYSUBITEMDRAW is returned in
{ // response to CDDS_ITEMPREPAINT.
*pResult = CDRF_DODEFAULT;
int iCol = lplvcd->iSubItem;
int iRow = lplvcd->nmcd.dwItemSpec;
if((iRow & 1))// && (iCol & 1)) // 单行
{
lplvcd->clrTextBk =m_clrLine; // RGB(255, 0, 0);
lplvcd->clrText =m_clrText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
else // 双行
{
lplvcd->clrTextBk =m_clrTwoLine; // RGB(255, 0, 0);
lplvcd->clrText =m_clrText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
if(GetItemState(iRow,LVIS_SELECTED))
{
lplvcd->clrTextBk =m_clrSelected; // RGB(255, 0, 0);
lplvcd->clrText =m_clrSelText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
break;
}
default:// it wasn't a notification that was interesting to us.
*pResult = CDRF_DODEFAULT;
}
}
//////////////////////////////////////////////////////////////////////////
// 增加背景色彩
void CXXSortListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYSUBITEMDRAW; // ask for subitem notifications.
break;
case CDDS_ITEMPREPAINT: // ask for subitem notifications.
*pResult = CDRF_NOTIFYSUBITEMDRAW;
if(GetExtendedStyle() & LVS_EX_CHECKBOXES)// if we have a checkbox style,
{ // forget about subitem notifications.
*pResult = CDRF_DODEFAULT;
int iRow = lplvcd->nmcd.dwItemSpec;
if((iRow & 1))// && (iCol & 1)) // 单行
{
lplvcd->clrTextBk =m_clrLine; // RGB(255, 0, 0);
lplvcd->clrText =m_clrText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
else // 双行
{
lplvcd->clrTextBk =m_clrTwoLine; // RGB(255, 0, 0);
lplvcd->clrText =m_clrText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
// 注意......... :)
// 这里就是你要更改的地方...
if(GetCheck(iRow)) // highlight checked rows
{
//lplvcd->clrTextBk =m_clrChkText; // RGB(255, 0, 0);
lplvcd->clrText =m_clrChkText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
}
break;
case CDDS_ITEMPREPAINT|CDDS_SUBITEM: // recd when CDRF_NOTIFYSUBITEMDRAW is returned in
{ // response to CDDS_ITEMPREPAINT.
*pResult = CDRF_DODEFAULT;
int iCol = lplvcd->iSubItem;
int iRow = lplvcd->nmcd.dwItemSpec;
if((iRow & 1))// && (iCol & 1)) // 单行
{
lplvcd->clrTextBk =m_clrLine; // RGB(255, 0, 0);
lplvcd->clrText =m_clrText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
else // 双行
{
lplvcd->clrTextBk =m_clrTwoLine; // RGB(255, 0, 0);
lplvcd->clrText =m_clrText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
if(GetItemState(iRow,LVIS_SELECTED))
{
lplvcd->clrTextBk =m_clrSelected; // RGB(255, 0, 0);
lplvcd->clrText =m_clrSelText; // RGB(255, 255, 0);
*pResult = CDRF_NEWFONT;
}
break;
}
default:// it wasn't a notification that was interesting to us.
*pResult = CDRF_DODEFAULT;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询