Author Topic: ListView Problems  (Read 192 times)

xandaz

  • Member
  • **
  • Posts: 152
  • I luv you babe
ListView Problems
« 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?
Code: [Select]
    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
nothing to report.

jj2007

  • Member
  • *****
  • Posts: 10644
  • Assembler is fun ;-)
    • MasmBasic
Re: ListView Problems
« Reply #1 on: August 15, 2020, 10:19:29 PM »
What happens if you use instead lvi.iSubItem,0?

HSE

  • Member
  • *****
  • Posts: 1404
  • <AMD>< 7-32>
Re: ListView Problems
« Reply #2 on: August 16, 2020, 01:14:39 AM »
Quote from: Win32 Help
You cannot use LVM_INSERTITEM to insert subitems

fearless

  • Member
  • ***
  • Posts: 480
    • LetTheLightIn
Re: ListView Problems
« Reply #3 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:
Code: [Select]
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:
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

My Github  Twitter

xandaz

  • Member
  • **
  • Posts: 152
  • I luv you babe
Re: ListView Problems
« Reply #4 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
nothing to report.