I am writting a new version of my small viewer program. In the previous version I used an ownerdraw listbox and there
were no problem. Today I decided to use a listview.
The problem I have is that I cannot get the drawing rectangle for each item.
Please help me.
Here is the source code.
; ================================================================================
RightImages_WmNotify PROC USES EBX EDI ESI,__hWnd:HWND,__dwControlId:DWord,__lpNmHdr:Ptr NMHDR
LOCAL _lpNmLvCustomDraw:Ptr NMLVCUSTOMDRAW
LOCAL _rc:RECT
cmp __dwControlId,IDC_LISTVIEW_01
jne @Exit
mov ebx,__lpNmHdr
cmp (NMHDR Ptr [ebx]).code,NM_CUSTOMDRAW
jne @Exit
mov _lpNmLvCustomDraw,ebx
mov eax,(NMLVCUSTOMDRAW Ptr [ebx]).nmcd.dwDrawStage
cmp eax,CDDS_PREPAINT
jne @NextMsg
mov eax,CDRF_NOTIFYITEMDRAW
jmp @Exit
@NextMsg :
cmp eax,CDDS_ITEMPREPAINT
jne @NextMsg_1
@NextMsg_0 :
INVOKE GFL_ResizeImageFromFile,(NMLVCUSTOMDRAW Ptr [ebx]).nmcd.lItemlParam,dwDiapo_Width,dwDiapo_Height
jz @EndDraw
mov edi,eax
mov _rc.left,LVIR_ICON
INVOKE SendMessage,hRightListView,LVM_GETSUBITEMRECT,(NMLVCUSTOMDRAW Ptr [ebx]).iSubItem,ADDR _rc
mov esi,(NMLVCUSTOMDRAW Ptr [ebx]).nmcd.hdc
INVOKE SetStretchBltMode,esi,HALFTONE
mov edx,(IMAGE_INFOS Ptr [edi]).Image.biWidth
mov ecx,(IMAGE_INFOS Ptr [edi]).Image.biHeight
INVOKE StretchDIBits,esi,_rc.left,_rc.top,edx,ecx,0,0,edx,ecx,(IMAGE_INFOS Ptr [edi]).lpImageBits,ADDR (IMAGE_INFOS Ptr [edi]).Image,DIB_RGB_COLORS,SRCCOPY
INVOKE M_Free,edi
@EndDraw :
mov eax,CDRF_NEWFONT
jmp @Exit
@NextMsg_1 :
cmp eax,CDDS_SUBITEM or CDDS_ITEMPREPAINT
je @NextMsg_0
@End :
mov eax,CDRF_DODEFAULT
@Exit :
ret
RightImages_WmNotify ENDP
; ================================================================================
Hey,Grincheux
searching "doodle" on this forum, the CustomDraw rectangle is about rightmenu.
what's the effect which you'll design?
Thank you 6L for your help, but now this problem is solved.
I have an other one. I don't receive any message to the listview.
I would like to draw something just behind the imae shown.
I have tried a lot of ideas by none is good.
Could you help me.
You can find the whole project at http://www.idcat39.com/download/IV3.zip
Bye
I kinda get the idea that NMLVCUSTOMDRAW doesnt do much for those purposes and its better to use LVS_OWNERDRAWFIXED right? What can you do really in NMCUSTOMDRAW? change the fonts? doesn't seem to do much. I was trying to do the item drawing myself but the strucutures are low in info.... Bye and laters