1、选中一行 当CListCtrl失去焦点时 此行依然处于选中状态(不是灰色显示,还是蓝色显示)
2、如何在LISTCTRL中的SUBITEM中显示图标.主要的是实现条件1
2、如何在LISTCTRL中的SUBITEM中显示图标.主要的是实现条件1
解决方案 »
- 这段代码看不懂g_hIcon = (HICON)LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_DISPLAYICON));真心谢你
- $$$CLlistCtrl SetItemPosition()失效
- 初学API
- 如何把2个工程合并到另一个工程中(刚接触VC不久,也不知道这么问对不对)
- 完成端口的客户端异常断开检测
- XP的网络功能 很强大,但为什么下面的命令没有用?(用户名和密码是有管理员权限的)
- 一个或多个多重定义的问题,到底错在哪?
- 怎样在工具栏上使用背景图?
- 谁给我DISKEDIT和DEBUG的详细用法?
- InstallShiled6.xx 制作的安装程序, 当安装时,一切看上去正常,不过指定目录下只有一个空文件夹,无任何文件,StarMenu->Program->可注册。
- zhucde(【风间苍月】) 进来领分!!!多谢!!!
- 大家进入看看解决一下问题谢谢
2.自画
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
//set default draw
*pResult = CDRF_DODEFAULT;
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))
{//paint the list control items and subitems
//get the number of item is going to paint
int nitem = static_cast<int> (pLVCD->nmcd.dwItemSpec);
//get the number of subitem is going to paint
int nsubitem = pLVCD->iSubItem;
//get first selected item position
POSITION npos = GetFirstSelectedItemPosition();
if(nitem == GetNextSelectedItem(npos)) //如果被选中使用自绘输出
{ //所画项是选中项
//get point of default dc objet
CDC* pdc = CDC::FromHandle(pLVCD->nmcd.hdc);
CString str;
CRect rect;
UINT nFormat = DT_VCENTER | DT_SINGLELINE;
//get rect of the sub item which is going to paint
GetSubItemRect(nitem, nsubitem, LVIR_BOUNDS, rect);
rect.left += 3; //调整自绘输出位置
//get the context is going to paint on the subitem
str = GetItemText(nitem,nsubitem);
pDC->SetTextColor(RGB(0,0,0));//字体颜色,因该是白色
pDC->FillSolidRect(&rect, RGB(255,255,255));//背景,深蓝色吧,试试
pDC->SetBkColor(RGB(255,255,255));//字体背景色,颜色同上
//set back is transparent
CSize msize;
//get the context length which is going to paint
msize = pdc->GetTextExtent(str);
//paint the text
pdc->DrawText(str, &rect, nFormat); //自绘输出
*pResult = CDRF_SKIPDEFAULT; // We've painted everything.
}
else
*pResult = CDRF_DODEFAULT;
}
}
2.http://expert.csdn.net/Expert/topic/2499/2499495.xml?temp=.0897333