Does anybody know how or have any links to source where listview lines are displayed in different colors? For example I want to display all files with sys attrib red, all others black. Is it possible?

thanks, and best regards,

czDrillard
Posted on 2001-11-17 15:22:52 by czDrillard
Hi,
yes, it IS possible. But not with a "normal" Listview.
If you use a "Virtual Listview", you can set every Item and Subitem in a different color or even font. I can post some ASM source for a Virtual Listview if you are interested (must dig it out first :-) )
Posted on 2001-11-17 15:55:37 by bazik
baZiK: what exactly is a Virtual Listview? Is it the same as an owner drawn listview or something totally different? I think colors can be set with owner drawn listviews too..
I'd like the source if you can find it..

Thomas
Posted on 2001-11-17 16:01:55 by Thomas
I don't have a full demo ready, but here are the most important parts, if you wanna use a VL (stripped from the source of my Mailclient):



[...]
WndProc proc hWin :DWORD,uMsg :DWORD, wParam :DWORD, lParam :DWORD

.if uMsg == WM_CREATE
[...]
; szListViewClass db "SysListView32", 0
invoke CreateWindowEx, WS_EX_CLIENTEDGE, addr szListViewClass, 0,
LVS_SHOWSELALWAYS or LVS_REPORT or WS_CHILD or WS_VISIBLE or LVS_OWNERDATA,
102, 48, 790, 404, hWin, ID_LISTVIEW, 400000h, 0
mov hList, eax
[...]
invoke CreateFont, 13, 0, 0, 0, FW_NORMAL,
0, 0, 0, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH, 0

invoke SendMessage, hList, WM_SETFONT, eax, 0
invoke SendMessage, hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT
invoke SendMessage, hList, LVM_SETITEMCOUNT, 0, LVSICF_NOINVALIDATEALL

mov lvc.imask, LVCF_TEXT or LVCF_WIDTH or LVCF_FMT
mov lvc.fmt, LVCFMT_CENTER
mov lvc.lx, 20
mov lvc.pszText, offset szCross
invoke SendMessage, hList, LVM_INSERTCOLUMN, 0, addr lvc

mov lvc.imask, LVCF_TEXT or LVCF_WIDTH or LVCF_FMT
mov lvc.fmt, 0
mov lvc.lx, 333
mov lvc.pszText, offset szSubject
invoke SendMessage, hList, LVM_INSERTCOLUMN, 1, addr lvc

mov lvc.imask, LVCF_TEXT or LVCF_WIDTH or LVCF_FMT
mov lvc.fmt, 0
mov lvc.lx, 250
mov lvc.pszText, offset szFrom
invoke SendMessage, hList, LVM_INSERTCOLUMN, 2, addr lvc

mov lvc.imask, LVCF_TEXT or LVCF_WIDTH or LVCF_FMT
mov lvc.fmt, LVCFMT_CENTER
mov lvc.lx, 102
mov lvc.pszText, offset szDateTime
invoke SendMessage, hList, LVM_INSERTCOLUMN, 3, addr lvc

mov lvc.imask, LVCF_TEXT or LVCF_WIDTH or LVCF_FMT
mov lvc.fmt, LVCFMT_RIGHT
mov lvc.lx, 64
mov lvc.pszText, offset szSize
invoke SendMessage, hList, LVM_INSERTCOLUMN, 4, addr lvc
[...]
.elseif uMsg == WM_NOTIFY

mov esi, lParam
assume esi:ptr NMHDR

.if ([esi].idFrom == ID_LISTVIEW && [esi].code == LVN_GETDISPINFO)

assume esi:ptr LV_DISPINFO

.if ([esi].item.imask & LVIF_TEXT)
[...]
mov [esi].item.pszText, offset szMailData1 ; text to set
[...]
.endif

.endif

.elseif uMsg == WM_CLOSE
[...]




If you do a search on google.com, you can dig out some more examples. But I've never seen an example in ASM. If I have some free time tomorrow, I'll put a small demo app together.
Gotta go to bed now :grin:

bAZiK
Posted on 2001-11-17 17:04:29 by bazik
Sorry if this is a bit off topic, but whats the max no of items a normal listview can hold? i cant find the info on msdn.

Also as for the coloured lines i believe you cna use the custom darw control. I am not sure but i believe it even has an example on exactly what you are looking for. So just go to msdn and take a look at custom draw.
Posted on 2001-11-18 01:07:14 by MovingFulcrum
Thanks to everybody for your replies, I didn't get back to board for a few days and found my post buried on page 2. Had to resurrect it in order to say thanks!

best regards,

czDrillard
Posted on 2001-11-20 09:18:09 by czDrillard