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. ListView-CustomDraw

ListView-CustomDraw

Scheduled Pinned Locked Moved C / C++ / MFC
c++com
1 Posts 1 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.
  • N Offline
    N Offline
    nitin3
    wrote on last edited by
    #1

    This code is taken from "http://www.codeproject.com/KB/list/lvcustomdraw.aspx" an MFC project. i made changes in the code to suitable for a Win32 project. But this code is not working. i am able to get CDDS_PREPAINT but not ITEMPREPAINT or (CDDS_ITEMPREPAINT | CDDS_SUBITEM).

    if( ((NMHDR*)lParam)->code == NM_CUSTOMDRAW )
    {
    pLVCD = reinterpret_cast<nmlvcustomdraw*>( lParam );

    if ( CDDS\_PREPAINT == pLVCD->nmcd.dwDrawStage )
    {
    	return CDRF\_NOTIFYITEMDRAW;
    }
    else if ( CDDS\_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
    {
    	return CDRF\_NOTIFYSUBITEMDRAW;
    }
    else if ( (CDDS\_ITEMPREPAINT | CDDS\_SUBITEM) == pLVCD->nmcd.dwDrawStage )
    {
    	COLORREF crText, crBkgnd;
    	
    	if ( 0 == pLVCD->iSubItem )
    	{
    		crText = RGB(255,0,0);
    		crBkgnd = RGB(128,128,255);
    	}
    	else if ( 1 == pLVCD->iSubItem )
    	{
    		crText = RGB(0,255,0);
    		crBkgnd = RGB(255,0,0);
    	}
    	else
    	{
    		crText = RGB(128,128,255);
    		crBkgnd = RGB(0,0,0);
    	}
    
    	pLVCD->clrText = crText;
    	pLVCD->clrTextBk = crBkgnd;
    
    return CDRF\_DODEFAULT;
    }
    

    }

    Thanks & Regards

    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