Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CListCtrl CustomDraw iSubItem

CListCtrl CustomDraw iSubItem

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Braulio Dez
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • B Braulio Dez

      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

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      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!

      B 2 Replies Last reply
      0
      • M Michael Dunn

        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!

        B Offline
        B Offline
        Braulio Dez
        wrote on last edited by
        #3

        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... :-(

        1 Reply Last reply
        0
        • M Michael Dunn

          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!

          B Offline
          B Offline
          Braulio Dez
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups