vc 如何将txt里的内容导入到ClistCtrl里,并且对应到每行每列
2个回答
展开全部
我给你列出来
//////////////////////////////////////////////////////////////////////////
// 增加背景色彩
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;
}
}
追问
这个是改变背景色的吗?我是要把txt里的内容按clistctrl对应的列导入到clistctrl里
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询