News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

ListView SubItems

Started by The Dude of Dudes, February 19, 2005, 11:02:25 PM

Previous topic - Next topic

The Dude of Dudes

I am trying to change text color of 1 Subitem in a report style ListView. My initialization code:

mov cmctlex.dwSize, sizeof cmctlex
mov cmctlex.dwICC, ICC_LISTVIEW_CLASSES
invoke InitCommonControlsEx, addr cmctlex


WinProc code:

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WinProc proc, hWnd: dword, uMsg: dword, wParam: dword, lParam: dword
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


.if uMsg == WM_NOTIFY
  mov ecx, lParam
  assume ecx: ptr NMLVCUSTOMDRAW
.if [ecx].nmcd.hdr.code == NM_CUSTOMDRAW
 
    .if [ecx].nmcd.dwDrawStage == CDDS_PREPAINT
       mov eax, CDRF_NOTIFYSUBITEMDRAW
       ret

    .elseif [ecx].nmcd.dwDrawStage == ( CDDS_ITEMPREPAINT or CDDS_SUBITEM)
.if ([ecx].nmcd.dwItemSpec == 0) && ([ecx].iSubItem == 1)
invoke Beep, 1000, 500
;Item Zero Subitem 1 is being drawn
.endif
    .endif
.endif
.endif

assume ecx: nothing



The Beep is there just to see if the  CDDS_SUBITEM code is ever processed, but it never is. What am I doing wrong?  :(

The Dude of Dudes

AHA! Problem solved:

.elseif uMsg == WM_NOTIFY
  mov ecx, lParam
  assume ecx: ptr NMLVCUSTOMDRAW
.if [ecx].nmcd.hdr.code == NM_CUSTOMDRAW
 
    .if [ecx].nmcd.dwDrawStage == CDDS_PREPAINT
       mov eax, CDRF_NOTIFYITEMDRAW
       ret

    .elseif [ecx].nmcd.dwDrawStage == CDDS_ITEMPREPAINT
mov eax, CDRF_NOTIFYSUBITEMDRAW
ret
    .elseif [ecx].nmcd.dwDrawStage == CDDS_SUBITEM or CDDS_ITEMPREPAINT
.if ([ecx].nmcd.dwItemSpec == 0) && ([ecx].iSubItem == 2)
invoke Beep, 1000, 500
;Item Zero Subitem 1 is being drawn
.endif
    .endif
.endif


assume ecx: nothing

.endif

donkey

It is fairly easy to change the drawing aspects of a listview. You can download my listview example from my website to take a look at how I handled the custom draw notification, it might help a bit.

http://donkey.visualassembler.com/files/TestListView.zip
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

The Dude of Dudes

Thanx for the example Donkey. It's interesting how you changed the background color of the text through the DC.  :U I had troubles highlighting isolated subitems.  Apparently you need to return CDRF_NOTIFYSUBITEMDRAW in response to the CDDS_ITEMPREPAINT message to be notified before each subitem is drawn. At first I was returning CDRF_NOTIFYSUBITEMDRAW in response to CDDS_PREPAINT. I missed the extra step. Works great now. I change the background color by setting the NMLVCUSTOMDRAW.clrTextBk with a COLORREF value and returning CDRF_NEWFONT. I might try using the DC instead, like in your example.