HI!

I have a problem to sending CDRF_NOTIFYITEMDRAW message to ListView.
I know how to do it, if we creating main window through CreateWindow and using ours Messageloop
for exampl:

.if uMsg==WM_NOTIFY

mov edi,lParam
ASSUME edi:PTR NMHDR
mov ebx,.code
mov eax,hList
.if .hwndFrom==eax
.if ebx==NM_CUSTOMDRAW
ASSUME edi:PTR NMLVCUSTOMDRAW
.if .nmcd.dwDrawStage == CDDS_PREPAINT
mov eax,CDRF_NOTIFYITEMDRAW
ret

But, how to return CDRF_NOTIFYITEMDRAW if i using DialogBoxParam ?
Posted on 2003-05-17 07:08:43 by ionik
msdn says:
Custom Draw With List-View Controls
Because list-view controls have subitems and multiple display modes, you will need to handle the NM_CUSTOMDRAW notification somewhat differently than for the other common controls.

For report mode:

The first NM_CUSTOMDRAW notification will have the dwDrawStage member of the associated NMCUSTOMDRAW structure set to CDDS_PREPAINT. Return CDRF_NOTIFYITEMDRAW.
You will then receive an NM_CUSTOMDRAW notification with dwDrawStage set to CDDS_ITEMPREPAINT. If you specify new fonts or colors and return CDRF_NEWFONT, all subitems of the item will be changed. If you want instead to handle each subitem separately, return CDRF_NOTIFYSUBITEMDRAW.
If you returned CDRF_NOTIFYITEMDRAW in the previous step, you will then receive an NM_CUSTOMDRAW notification for each subitem with dwDrawStage set to CDDS_SUBITEM | CDDS_PREPAINT. To change the font or color for that subitem, specify a new font or color and return CDRF_NEWFONT.
For the large icon, small icon, and list modes:

The first NM_CUSTOMDRAW notification will have the dwDrawStage member of the associated NMCUSTOMDRAW structure set to CDDS_PREPAINT. Return CDRF_NOTIFYITEMDRAW.
You will then receive an NM_CUSTOMDRAW notification with dwDrawStage set to CDDS_ITEMPREPAINT. You can change the fonts or colors of an item by specifying new fonts and colors and returning CDRF_NEWFONT. Because these modes do not have subitems, you will not receive any additional NM_CUSTOMDRAW notifications.

check out this code and you will see what you are missing
.elseif uMsg==WM_NOTIFY

mov edi,lParam ;move info into edi
assume edi:ptr NMHDR ;make edi point to the NMHDR structure
mov eax,[edi].hwndFrom
.if eax == hList
.if [edi].code==NM_CUSTOMDRAW
assume edi:ptr NMLVCUSTOMDRAW
.if [edi].nmcd.dwDrawStage == CDDS_PREPAINT
mov eax,CDRF_NOTIFYITEMDRAW
ret
.elseif [edi].nmcd.dwDrawStage == CDDS_ITEMPREPAINT
mov eax,CDRF_NOTIFYSUBITEMDRAW
ret
.elseif [edi].nmcd.dwDrawStage == CDDS_ITEMPREPAINT || CDDS_SUBITEM
;;;;;;;do stuff in this section
.if [edi].iSubItem == 0

.endif
;;;;;;;stop doing crap
mov eax, CDRF_NEWFONT
ret
.endif
.endif
.endif
Posted on 2003-05-17 09:57:15 by smurf
If you are using the listview in a modal dialog box the return message seems to get lost and you never get the extra item draw events. You need to return the messages in a different way....

So instead of just returning CDRF_NOTIFYITEMDRAW in eax, you may need to do this also...

To return from the CDDS_PREPAINT add..

invoke SetWindowLong,hWnd,DWL_MSGRESULT,CDRF_NOTIFYITEMDRAW


You can similarly return the new values in the CDDS_SUBITEM||CDDS_ITEMPREPAINT by using

invoke SetWindowLong,hWnd,DWL_MSGRESULT,CDRF_NEWFONT


Took me ages to figure that one out, and i think someone on the board pointed me in the right direction!
Posted on 2003-05-17 11:13:56 by MurkyT
Thank for the answer MurkyT now it's work :alright:
Posted on 2003-05-17 12:17:47 by ionik
Hello again, now i have next problem : how I can find out iItem(Item number)
when NM_CUSTOMDRAW is received, and why need send CDRF_NEWFONT, it's work fine without it.
Posted on 2003-05-18 02:57:17 by ionik
If you look at Smurfs code up above...there are references in there to iSubItem...you can reference the iItem in exactly the same way. As for returning CDRF_NEWFONT, I think you'll find when you start changing things in the CDDS_ITEMPREPAINT, if you don't return that value the changes won't apply.
Posted on 2003-05-18 11:22:40 by MurkyT
Thank for the answer MurkyT, as for my previous question in NMLVCUSTOMDRAW STRUCT nmcd.dwItemSpec shows the iItem that will be repainted. By the way MurkyT, how you create column head with sunken? style in cdLV component ?
Posted on 2003-05-21 15:47:39 by ionik
Use message LVM_GETHEADER to get handle to header control. Then use GetWindowLong/SetWindowLong on that handle to add HDS_FLAT to GWL_STYLE of that header control.
Posted on 2003-05-21 16:20:37 by comrade
C?????? ?? ????? ??????? ?????.
Thank for the fast answer.
HDS_FLAT equ ?????
Posted on 2003-05-22 01:17:08 by ionik
??????, ??? ????? ??????? ????? ??? ?? ?????? ??????????.

You need to take out HDS_BUTTONS flag, not add HDS_FLAT flag:
hHeader = SendMessage(hListView, LVM_GETHEADER, 0, 0);

dwStyle = GetWindowLong(hHeader, GWL_STYLE);
dwStyle = dwStyle & (!HDS_BUTTONS); ; style = style AND (NOT HDS_BUTTONS)
SetWindowLong(hHeader, GWL_STYLE, dwStyle);
Posted on 2003-05-22 07:23:09 by comrade