The MASM Forum

General => The Campus => Topic started by: xandaz on August 15, 2020, 08:35:29 PM

Title: ListView Problems
Post by: xandaz on August 15, 2020, 08:35:29 PM
   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
Title: Re: ListView Problems
Post by: jj2007 on August 15, 2020, 10:19:29 PM
What happens if you use instead lvi.iSubItem,0?
Title: Re: ListView Problems
Post by: HSE on August 16, 2020, 01:14:39 AM
Quote from: Win32 HelpYou cannot use LVM_INSERTITEM to insert subitems
Title: Re: ListView Problems
Post by: fearless on August 16, 2020, 02:19:29 AM
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:
Title: Re: ListView Problems
Post by: xandaz on August 16, 2020, 05:04:37 AM
   Thanks guys for the help. I ended up managing it with LVM_SETITEM. Worked like a charm. Thanks again for the help