CListCtrl CustomDraw iSubItem
-
Hi, I'm calling CListCtrl CustomDraw from a dialog, and I'm getting in trouble when I try to retrieve the column number that is currently being drawn ( I get a column number like 1242244). What I make is:
void CRolesDlg::OnCustomdrawRoles(NMHDR* pNMHDR, LRESULT* pResult ) { (...) LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR; int iCol = lplvcd->iSubItem; (...) }
And I get that strange iCol number :-(, any ideas about why this happens ? It's a bug from MFC ? A bad casting ? Greetings Braulio -
Hi, I'm calling CListCtrl CustomDraw from a dialog, and I'm getting in trouble when I try to retrieve the column number that is currently being drawn ( I get a column number like 1242244). What I make is:
void CRolesDlg::OnCustomdrawRoles(NMHDR* pNMHDR, LRESULT* pResult ) { (...) LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR; int iCol = lplvcd->iSubItem; (...) }
And I get that strange iCol number :-(, any ideas about why this happens ? It's a bug from MFC ? A bad casting ? Greetings BraulioYou left out a lot of code there... are you checking the draw stage? Returning the right CDRF_* flags to get notified of the draw stage for subitems? --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but if we shaved our heads, we'd look like weasels!
-
You left out a lot of code there... are you checking the draw stage? Returning the right CDRF_* flags to get notified of the draw stage for subitems? --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but if we shaved our heads, we'd look like weasels!
Hi Michael, The full code of the method is:
void CRolesDlg::OnCustomdrawRoles(NMHDR* pNMHDR, LRESULT* pResult ) { NMLVCUSTOMDRAW* customDrawItem = reinterpret_cast(pNMHDR); LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR; int iCol = lplvcd->iSubItem; int iRow =0; switch(lplvcd->nmcd.dwDrawStage) { /*case CDDS_PREPAINT: *pResult = CDRF_NOTIFYITEMDRAW; // ask for item notifications. break; case CDDS_ITEMPREPAINT: *pResult = CDRF_DODEFAULT; if(lplvcd->iSubItem == 1) { //CString Aux = m_lcTrades.GetItemText(iRow, 0); //if(Aux.Find(".") == -1) { // Undercode... root codes cannot be selected lplvcd->clrTextBk = RGB(225, 225, 225); lplvcd->clrText = RGB(0, 0, 0); *pResult = CDRF_NEWFONT; } break;*/ case (CDDS_SUBITEM): if(lplvcd->iSubItem == 1) { AfxMessageBox(""); } break; default: *pResult = CDRF_DODEFAULT; } }
I tried several things... :-( -
You left out a lot of code there... are you checking the draw stage? Returning the right CDRF_* flags to get notified of the draw stage for subitems? --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but if we shaved our heads, we'd look like weasels!
Hi Michale, I'm following you article "Neat Sutff to do in List Controls Using Custom Draw", now things are going better :-) I hate to do things like this with MFC/ATL... when guys making shit with Visual Basic can do it in five minutes :-( Thanks for your help, Bye ! Braulio