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. Changing Individual Item Background Color of listview (need win32 non MFC)

Changing Individual Item Background Color of listview (need win32 non MFC)

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
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.
  • A Offline
    A Offline
    author
    wrote on last edited by
    #1

    i have a dll containing a function which creates a listview and returns the handle for the listview. i have another function which hooks into the window procedure of this newly created listview so that it can change the background color of individual items. It uses SetWindowLong to trap the window procedure. Am i doing it right ? The sample code is as below: listviewhandle=alMakeListView(AWPARAM_PTR awParam,long x ,long y,long width,long height); void WINAPI EXPORT alListChangeItemColor(HWND listviewhandle) { glPrevWndProc = SetWindowLong(listviewhandle, GWL_WNDPROC,(LONG)(WNDPROC)DoNotify); } LRESULT DoNotify(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_NOTIFY: { LPNMLISTVIEW pnm = (LPNMLISTVIEW)lParam; switch (pnm->hdr.code) { case NM_CUSTOMDRAW: { LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam; return(CDRF_DODEFAULT); if(lplvcd->nmcd.dwDrawStage == CDDS_PREPAINT) return CDRF_NOTIFYITEMDRAW; if(lplvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) { COLORREF crText; if(!(lplvcd->nmcd.dwItemSpec % 3)) { crText=RGB(255, 0, 0); lplvcd->clrText = crText; lplvcd->clrTextBk = RGB(0,0,0); } } } default: break; } } } return CallWindowProc((WNDPROC)glPrevWndProc, hwnd, msg, wParam, lParam); } Can anybody tell me what is going wrong with this code ? Been trying this for some time now and can't figure it out. author :confused:

    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