Hey guys,

ptrSection points on a 12 bytes vriable. The first 4 bytes are a string, bytes 5 to 8 are a 32bit number. I want to add the 4 bytes string as listitem and the 32bit number as a sub list item. The first one works out except that it print's more than the first 4 bytes. The second one, the number, doesn't work at all!
Please help me! :confused:

Here is my code .. might be a little funny, but hey I'm a beginner :d

AddListItem proc ptrSection:DWORD
LOCAL lvi:LV_ITEM
LOCAL buffer[10]:BYTE

mov lvi.imask,LVIF_TEXT+LVIF_PARAM
push ddSectionCount
pop lvi.iItem
mov lvi.iSubItem,0
push
pop lvi.pszText
push ddSectionCount
pop lvi.lParam
invoke SendMessage,hListSections,LVM_INSERTITEM,NULL,ADDR lvi
mov lvi.imask,LVIF_TEXT
inc lvi.iSubItem
invoke wsprintf,ADDR buffer,ADDR ListSectionsTemplate,
lea eax,buffer
push
pop lvi.pszText
invoke SendMessage,hListSections,LVM_SETITEM,NULL,ADDR lvi
ret
AddListItem endp

Thanx!

yaXay
Posted on 2003-11-15 17:59:16 by yaXay
Hi again :)

Maybe it's push ptrSection rather than push ... :confused:

I'm definitely sure that does not work. You can't use a pointer that's inside a variable in an address calculation. That instruction is not retrieving the second DWORD of your data, but the next 4 bytes past the "ptrSection" parameter in the stack. You should instead do something like:
mov eax,ptrSection

add eax,4
invoke wsprintf,ADDR buffer,ADDR ListSectionsTemplate,eax

Also make sure to get the item's index as returned by the LVM_INSERTITEM message.

Hope it helps! ;)
Posted on 2003-11-15 18:42:05 by QvasiModo