CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2001
    Posts
    4

    CHeaderCtrl background color.

    Hello:
    I want to color the background of the header of a CListCtrl control.

    Could anyone help me!

    Thanks.


  2. #2
    Join Date
    Jun 2012
    Posts
    1

    Re: CHeaderCtrl background color.

    if you want is changing color of main column list of CListCtrl...
    i tried this, and i could not this, but, finally, i did....write for memory

    1.make sub class of CHeaderCtrl. it is a derived class of CHeaderCtrl.
    2.massage fuction about NM_CUSTOMDRAW is needed..
    3.if above is ok, the function like "void ~~~::OnNMCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)" are made.
    4.code is..
    void COwnHeader::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
    {
    //for this notification, the structure is actually a
    // NMLVCUSTOMDRAW that tells you what's going on with the custom
    // draw action. So, we'll need to cast the generic pNMHDR pointer.
    LPNMCUSTOMDRAW lplvcd = (LPNMCUSTOMDRAW)pNMHDR;

    switch(lplvcd->dwDrawStage)
    {
    case CDDS_PREPAINT:
    *pResult = CDRF_NOTIFYITEMDRAW;
    break;
    case CDDS_ITEMPREPAINT:
    {
    CDC *pDC_ = CDC::FromHandle(lplvcd->hdc);
    CRect rcItem(lplvcd->rc);
    pDC_->FillSolidRect(rcItem, m_clrBk);
    }
    break;
    default:// it wasn't a notification that was interesting to us.
    *pResult = CDRF_DODEFAULT;
    break;
    }
    }

  3. #3
    Join Date
    Jan 2002
    Location
    Houston, TX
    Posts
    1,420

    Re: CHeaderCtrl background color.

    The OP has probably solved this himself, or given up, or died, or moved to an isolated island

    in the past 11 years!
    Be sure to rate those who help!
    -------------------------------------------------------------
    Karl - WK5M
    PP-ASEL-IA (N43CS)
    PGP Key: 0xDB02E193
    PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

  4. #4
    Join Date
    Oct 2011
    Posts
    97

    Re: CHeaderCtrl background color.

    This seems to be quite common lately. CodeGuru should install that vBulletin plugin that warns you when you're about to reply to an old thread like this. (Or does it already? I've never tried. )

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts



HTML5 Development Center

Click Here to Expand Forum to Full Width