ListView Notification Example win32
-
How about a win32 example which shows how to change the background color of individual items of a listview control ? I have been trying to find and know how to do this but till now without much success :( author
See Neat Stuff to do in List Controls Using Custom Draw. It uses MFC, but it's just message handling so it'll be simple to change the message handler over to straight Win32. --Mike-- http://home.inreach.com/mdunn/ This posting is provided "as was" with no warranties, guarantees, lotteries, or any of those little bags of peanuts you get on planes. You assume all risk for crossing the street without holding mommy's hand. © 2001 Mike's Classy Software. Member FDIC. If rash develops, discontinue use. :love: your :bob: with :vegemite: and :beer:
-
See Neat Stuff to do in List Controls Using Custom Draw. It uses MFC, but it's just message handling so it'll be simple to change the message handler over to straight Win32. --Mike-- http://home.inreach.com/mdunn/ This posting is provided "as was" with no warranties, guarantees, lotteries, or any of those little bags of peanuts you get on planes. You assume all risk for crossing the street without holding mommy's hand. © 2001 Mike's Classy Software. Member FDIC. If rash develops, discontinue use. :love: your :bob: with :vegemite: and :beer:
Hi Michael Thanks for replying. I have seen that code. but it doesn't seemt o work for me in Win32 or maybe I have done something wrng i just can't figure it out. :confused: Would appreciate help on this. I have posted the problem yesterday in the Visual C++ discussion board but nobody replied. I have given details of my problem there and I can't seem to figure out the problem. I will put the stuff here again. I am making a win32 dll (non MFC) and i have these three functions which I am using (i have more functions but may not be exactly useful here) HWND WINAPI EXPORT MakeListView(HWND hwnd,long x ,long y,long width,long height) { INITCOMMONCONTROLSEX iccex; iccex.dwICC=ICC_LISTVIEW_CLASSES; //ICC_WIN95_CLASSES; iccex.dwSize=sizeof(INITCOMMONCONTROLSEX); InitCommonControlsEx(&iccex); hwndTT = CreateWindow("SysListView32","",WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SHOWSELALWAYS , x, y,width,height,awParam->hwnd, NULL, hInst, NULL); ListView_SetExtendedListViewStyle(hwndTT, LVS_EX_FULLROWSELECT ); //initialize the LVCOLUMN structure //The LVCOLUMN is used for adding title to the header of listview. lvc.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.cx=100; lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE; lvi.state = 0; lvi.stateMask = 0; return(hwndTT); } //The above sample code is for making a listview and it returns a handle void WINAPI EXPORT ListChangeItemColor(HWND listviewhandle) { glPrevWndProc = SetWindowLong(listviewhandle, GWL_WNDPROC,(LONG)(WNDPROC)DoNotify); } //this is the second function which accepts the listviewhandle and attempts to use the window procedure of the ListView. I think this is the problem, not sure if i am doing this right. long 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; if(lplvcd->nmcd.dwDrawStage == CDDS_PREPAINT) return CDRF_NOTIFYITEMDRAW; if(lplvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) { if(!(lplvcd->nmcd.dwItemSpec % 3)) { GetClientRect(hwnd,&rect); MessageBox(NULL,"I am here","help",MB_OK); lplvcd->clrText =RGB(255, 0, 0); lplvcd->clrTextBk = RGB(0,0,0); InvalidateRect(hwnd,&rect,FALSE); return(CDRF_DODEFAULT); } } } } }