News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

ListView Problems

Started by xandaz, August 15, 2020, 08:35:29 PM

Previous topic - Next topic

xandaz

   Hi huys. I'm having trouble adding items to the second row of my list view control. Shouldnt lvi.iSubItem=1 direct the item to the second row?
    mov     lvi.imask,LVIF_TEXT
    mov     lvi.iItem,0
    mov     lvi.iSubItem,0
    mov     lvi.pszText,offset rarhdx.FileNameW
    invoke  SendMessage,hListView,LVM_INSERTITEM,0,addr lvi
    inc     lvi.iItem
    mov     eax,rarhdx.FileCRC
    lea     ebx,hex_xlat
    lea     edi,UnpSizeBuffer
    mov     ecx,4
    cld
loop_1:   
    rol     eax,4
    push    eax
    and     ax,1111b
    xlat
    stosw
    pop     eax
    loop    loop_1
    xor     ah,ah
    mov     al,'h'
    stosw
    mov     al,0
    stosw
    mov     lvi.iSubItem,1
    mov     lvi.cchTextMax,6
    mov     lvi.pszText,offset UnpSizeBuffer
    invoke  SendMessage,hListView,LVM_INSERTITEM,0,addr lvi

jj2007

What happens if you use instead lvi.iSubItem,0?

HSE

Quote from: Win32 HelpYou cannot use LVM_INSERTITEM to insert subitems
Equations in Assembly: SmplMath

fearless

I use a couple of functions to help with inserting items and subitems:

https://github.com/mrfearless/libraries/blob/master/Listview/Listview%20x86/ListViewInsertItem.asm

and


https://github.com/mrfearless/libraries/blob/master/Listview/Listview%20x86/ListViewInsertSubItem.asm

Just have to start at index 0 for list items and increment that with a variable after using ListViewInsertItem function and then to set subitems (columns) use the existing row index variable and start at subitem 1 for column 1, 2 for col 2 etc.
Use is something like:
mov ListItemIndex, 0

Invoke ListViewInsertItem, hLV, ListItemIndex, Addr szCol0Data, 0
Invoke ListViewInsertSubItem, hLV, ListItemIndex, 1, Addr szCol1Data
Invoke ListViewInsertSubItem, hLV, ListItemIndex, 2, Addr szCol2Data
Invoke ListViewInsertSubItem, hLV, ListItemIndex, 3, Addr szCol3Data

inc ListItemIndex

; insert next row and sub items:

xandaz

   Thanks guys for the help. I ended up managing it with LVM_SETITEM. Worked like a charm. Thanks again for the help