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. how to change the highlight color of listctrl

how to change the highlight color of listctrl

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
7 Posts 3 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.
  • G Offline
    G Offline
    GANsJob
    wrote on last edited by
    #1

    Hi all, Im using custom draw to change the color or the listctel item. But i cant change the highlight color . how can i get it done. thankx regards GAN

    T H 2 Replies Last reply
    0
    • G GANsJob

      Hi all, Im using custom draw to change the color or the listctel item. But i cant change the highlight color . how can i get it done. thankx regards GAN

      T Offline
      T Offline
      Tara14
      wrote on last edited by
      #2

      If you want to highlight a particular row, try this in your OnCustomdrawList function:

      COLORREF crText, crBkgnd;
      if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
      {
      if ( (pLVCD->nmcd.dwItemSpec % 3) == 2 )
      {
      LOGFONT lfFont;
      CFont *pFont = GetFont();

      		\_ASSERTE( pFont );
      		pFont -> GetLogFont( &lfFont );
      		CFont m\_fBFont;
      		m\_fBFont.CreateFontIndirect( &lfFont );
      		SelectObject(pLVCD->nmcd.hdc,m\_fBFont);
      
      		
      		crText = RGB(255,0,0); // sets text color
      		crBkgnd = RGB(255,255,0); // sets text background/highlight color
                             
      		pLVCD->clrText = crText;
      		pLVCD->clrTextBk = crBkgnd;
      	 }
          \*pResult = CDRF\_NEWFONT;
      
      
          }
      

      }

      To color the background of a particular column, try this:

      if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
      {
      COLORREF crText,crBkgnd;
      if (0 == pLVCD->iSubItem) // for column 0
      {
      crText = RGB(128,0,225);
      crBkgnd = RGB(247,241,202);
      }
      else
      if (1 == pLVCD->iSubItem) //for column 1
      {
      crText = RGB(0,128,0);
      crBkgnd = RGB(247,241,202);
      }
      pLVCD->clrText = crText;
      pLVCD->clrTextBk = crBkgnd;
      // Tell Windows to paint the control itself.
      *pResult = CDRF_DODEFAULT;
      }

      _


      Fortitudine Vincimus!_

      G 1 Reply Last reply
      0
      • T Tara14

        If you want to highlight a particular row, try this in your OnCustomdrawList function:

        COLORREF crText, crBkgnd;
        if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
        {
        if ( (pLVCD->nmcd.dwItemSpec % 3) == 2 )
        {
        LOGFONT lfFont;
        CFont *pFont = GetFont();

        		\_ASSERTE( pFont );
        		pFont -> GetLogFont( &lfFont );
        		CFont m\_fBFont;
        		m\_fBFont.CreateFontIndirect( &lfFont );
        		SelectObject(pLVCD->nmcd.hdc,m\_fBFont);
        
        		
        		crText = RGB(255,0,0); // sets text color
        		crBkgnd = RGB(255,255,0); // sets text background/highlight color
                               
        		pLVCD->clrText = crText;
        		pLVCD->clrTextBk = crBkgnd;
        	 }
            \*pResult = CDRF\_NEWFONT;
        
        
            }
        

        }

        To color the background of a particular column, try this:

        if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
        {
        COLORREF crText,crBkgnd;
        if (0 == pLVCD->iSubItem) // for column 0
        {
        crText = RGB(128,0,225);
        crBkgnd = RGB(247,241,202);
        }
        else
        if (1 == pLVCD->iSubItem) //for column 1
        {
        crText = RGB(0,128,0);
        crBkgnd = RGB(247,241,202);
        }
        pLVCD->clrText = crText;
        pLVCD->clrTextBk = crBkgnd;
        // Tell Windows to paint the control itself.
        *pResult = CDRF_DODEFAULT;
        }

        _


        Fortitudine Vincimus!_

        G Offline
        G Offline
        GANsJob
        wrote on last edited by
        #3

        how to change the highlight color of listctrl IM ASKING FOR CHANGING HIGHLIGHT COLOR OF THE LISTCTEL -- modified at 8:13 Friday 18th August, 2006

        T 1 Reply Last reply
        0
        • G GANsJob

          Hi all, Im using custom draw to change the color or the listctel item. But i cant change the highlight color . how can i get it done. thankx regards GAN

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          See Another Report List Control[^] maybe it is some helpful to you

          _**


          **_

          WhiteSky


          1 Reply Last reply
          0
          • G GANsJob

            how to change the highlight color of listctrl IM ASKING FOR CHANGING HIGHLIGHT COLOR OF THE LISTCTEL -- modified at 8:13 Friday 18th August, 2006

            T Offline
            T Offline
            Tara14
            wrote on last edited by
            #5

            GANsJob wrote:

            highlight color of listctrl

            A list has many parts - headers, rows or items, columns or subitems.... The text color of each can be changed; the background color (or what you call "highlight" color of each individual part can be changed. When you say, "Change the highlight colour of listctrl please specify which part of the listctrl you mean.

            _


            Fortitudine Vincimus!_

            G 1 Reply Last reply
            0
            • T Tara14

              GANsJob wrote:

              highlight color of listctrl

              A list has many parts - headers, rows or items, columns or subitems.... The text color of each can be changed; the background color (or what you call "highlight" color of each individual part can be changed. When you say, "Change the highlight colour of listctrl please specify which part of the listctrl you mean.

              _


              Fortitudine Vincimus!_

              G Offline
              G Offline
              GANsJob
              wrote on last edited by
              #6

              When you say, "Change the highlight colour of listctrl please specify which part of the listctrl you mean. Selected item's higlight color

              T 1 Reply Last reply
              0
              • G GANsJob

                When you say, "Change the highlight colour of listctrl please specify which part of the listctrl you mean. Selected item's higlight color

                T Offline
                T Offline
                Tara14
                wrote on last edited by
                #7

                Take a look at this article http://www.codeproject.com/listctrl/ListSubItSel.asp[^] It might be of help to you.

                _


                Fortitudine Vincimus!_

                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