السلام عليكم
وجدت هدا الكود في برنامج للاخ GM وهو لتلوين الكتابة في ListeView
.elseif Msg == WM_NOTIFY ; capture notify routine
mov esi, LParam
assume esi : ptr NMLVCUSTOMDRAW
;capture custom draw and make sure we are going to draw our listview
.if ([esi].nmcd.hdr.code == NM_CUSTOMDRAW && [esi].nmcd.hdr.idFrom == 1005)
.if ([esi].nmcd.dwDrawStage == CDDS_PREPAINT)
; before painting, aquire subitems draw notify
mov eax, CDRF_NOTIFYITEMDRAW
.elseif ([esi].nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
; same
mov eax, CDRF_NOTIFYITEMDRAW
.elseif ([esi].nmcd.dwDrawStage == (CDDS_ITEMPREPAINT or CDDS_SUBITEM))
; drawing subitems, we are doing our job here
; remember that we want to custom draw the "instruction" subitems only and not the whole rows ;)
.if ([esi].iSubItem == 0) ; the PiD column
; get the instruction string
invoke RtlZeroMemory, addr text, sizeof text
invoke RtlZeroMemory, addr lvi, sizeof lvi
m2m lvi.iItem, [esi].nmcd.dwItemSpec
mov lvi.iSubItem, 2
mov lvi.imask, LVIF_TEXT
lea eax, text
mov lvi.pszText, eax
mov lvi.cchTextMax, sizeof text
invoke SendMessage, [esi].nmcd.hdr.hwndFrom, LVM_GETITEM, NULL, addr lvi
; is it a "Ahmed18/AT4RE" instruction ??
invoke crt_strncmp, addr text, CTXT("Ahmed18/AT4RE"),13
.if (!eax)
; select our prefered font object
invoke SelectObject, [esi].nmcd.hdc, DisasmFont
; set the "Ahmed18/AT4RE" instruction prefered color (RGB system)
mov [esi].clrText, 0A00000h
mov eax, CDRF_NEWFONT
.endif
.endif
.if ([esi].iSubItem == 1) ; the Parent PID column
; get the Parent PID string
invoke RtlZeroMemory, addr text, sizeof text
invoke RtlZeroMemory, addr lvi, sizeof lvi
m2m lvi.iItem, [esi].nmcd.dwItemSpec
mov lvi.iSubItem,0
mov lvi.imask, LVIF_TEXT
lea eax, text
mov lvi.pszText, eax
mov lvi.cchTextMax, sizeof text
invoke SendMessage, [esi].nmcd.hdr.hwndFrom, LVM_GETITEM, NULL, addr lvi
invoke crt_strncmp, addr text, CTXT("Ahm"),3
.if (!eax)
; select our prefered font object
invoke SelectObject, [esi].nmcd.hdc, DisasmFont
; set the "Ahm" instruction prefered color (RGB system)
mov [esi].clrText, 080808h
mov eax, CDRF_NEWFONT
.endif
.endif
.if ([esi].iSubItem == 2) ; the Priority column
; select our prefered font object
invoke SelectObject, [esi].nmcd.hdc, DisasmFont
mov [esi].clrText, 08FFFFh
mov eax, CDRF_NEWFONT
.endif
.else
mov eax, CDRF_DODEFAULT
.endif
;send the custom draw result
invoke SetWindowLong, Hwnd, DWL_MSGRESULT, eax
xor eax, eax
inc eax
ret
.endif
assume esi : nothing
xor eax, eax
retكنت سابقا استعمل هدا الماكرو لتلوين النصوص
RGB macro red,bleu,green mov ah,green shl eax,8 mov ah,bleu mov al,bleu endm
تم اسناد الرسالة
RGB 50,50,188 invoke SendMessage,hListeViewp,LVM_SETTEXTCOLOR,0,eax
لكن عيب هده الطريقة انها تلون جميع خانات ListeView بنفس اللون .
في كود الاخ GM بالامكان التلاعب بالالوان واسناد عدة الوان مختلفة
اريد تطبيق الكود مع تغيير clrText بـ clrTextBk
لكني لم افهم الكود من الاول
السطور الاولى مفهومة
فقط هدا الشطر غير واضح
.if ([esi].iSubItem == 0) ; the PiD column
; get the instruction string
invoke RtlZeroMemory, addr text, sizeof text
invoke RtlZeroMemory, addr lvi, sizeof lvi
m2m lvi.iItem, [esi].nmcd.dwItemSpec
mov lvi.iSubItem, 2
mov lvi.imask, LVIF_TEXT
lea eax, text
mov lvi.pszText, eax
mov lvi.cchTextMax, sizeof text
invoke SendMessage, [esi].nmcd.hdr.hwndFrom, LVM_GETITEM, NULL, addr lvi
; is it a "Ahmed18/AT4RE" instruction ??
invoke crt_strncmp, addr text, CTXT("Ahmed18/AT4RE"),13
.if (!eax)
; select our prefered font object
invoke SelectObject, [esi].nmcd.hdc, DisasmFont
; set the "Ahmed18/AT4RE" instruction prefered color (RGB system)
mov [esi].clrText, 0A00000h
mov eax, CDRF_NEWFONT
.endif
.endif
.if ([esi].iSubItem == 1) ; the Parent PID column
; get the Parent PID string
invoke RtlZeroMemory, addr text, sizeof text
invoke RtlZeroMemory, addr lvi, sizeof lvi
m2m lvi.iItem, [esi].nmcd.dwItemSpec
mov lvi.iSubItem,0
mov lvi.imask, LVIF_TEXT
lea eax, text
mov lvi.pszText, eax
mov lvi.cchTextMax, sizeof text
invoke SendMessage, [esi].nmcd.hdr.hwndFrom, LVM_GETITEM, NULL, addr lvi
invoke crt_strncmp, addr text, CTXT("Ahm"),3
.if (!eax)
; select our prefered font object
invoke SelectObject, [esi].nmcd.hdc, DisasmFont
; set the "Ahm" instruction prefered color (RGB system)
mov [esi].clrText, 080808h
mov eax, CDRF_NEWFONT
.endif
.endif
.if ([esi].iSubItem == 2) ; the Priority column
; select our prefered font object
invoke SelectObject, [esi].nmcd.hdc, DisasmFont
mov [esi].clrText, 08FFFFh
mov eax, CDRF_NEWFONT
.endif
.else
mov eax, CDRF_DODEFAULT
.endif
;send the custom draw result
invoke SetWindowLong, Hwnd, DWL_MSGRESULT, eax
xor eax, eax
inc eax
ret
.endif
assume esi : nothing
xor eax, eax
retومادا تعني CDRF_NOTIFYITEMDRAW فلم اجدها هنا
http://msdn.microsoft.com/en-us/library/bb774778(VS.85).aspx
ايضا هدا السطر لاحظت انه استعمل كلمة غريبة m2m ??
m2m lvi.iItem, [esi].nmcd.dwItemSpec
