News:

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

Main Menu

ListView subitem editing

Started by K_F, October 24, 2013, 02:30:39 AM

Previous topic - Next topic

K_F

Hi... Somewhere over here there was a ListView (detail/report mode) example where you could edit a subitem.
I know of using a modified edit box laid over the cell, but I'm sure this example shows an easier method !!

I've tried search.. but nothing has popped up. I vaguely remember it.. but if anyone has it or a link... pleeezze  :bgrin:

Thanks
Van

'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

Tedd

Potato2

K_F

If I not mistaken, you can only edit the Item with LVM_EDITLABEL, not the subitem, as you'll need an Item and SubItem number to locate it.
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

fearless

http://www.masmforum.com/board/index.php?topic=17551.0 is an example i had that allowed editing of the subitems to display dropdown combos, dropdown lists or editboxes. Hope that helps, there is a couple other links in that old forum post that points to a few sources i referred to whilst making my own example.

K_F

Thanks Fearless.. I think that looks similar to what I'm thinking... I read through it  :t
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

K_F

Problem solved,... quite neatly actually..
I used a hidden EditBox.. which I just repositioned (and Zordered) depending where you clicked in the List View
Just must do the Edit Box proc to transfer the changes back to the Item or subItem, and do the column width changes as well.
:eusa_boohoo:

Quote.elseif ebx == NM_DBLCLK
         Invoke FillBuffer, ADDR myLVHitTest, sizeof LV_HITTESTINFO, 0
         Invoke FillBuffer, ADDR myLVItem, sizeof LV_ITEM, 0
         Invoke FillBuffer, ADDR myRect, sizeof RECT, 0
         ;--------------------
         ; Get Cursor Position
         ;--------------------
         invoke GetMessagePos
         mov      ebx, eax
         LoWord   ebx
         mov      myLVHitTest.pt.x, eax
         HiWord   ebx
         mov      myLVHitTest.pt.y, eax
         ;----------------------------------
         ; Convert Screen CoOrds to ListView
         ;----------------------------------
         invoke   ScreenToClient, myControlz.hlvResults,ADDR myLVHitTest.pt
         ;---------------------
         ; Find hit LV position
         ;---------------------
         invoke    SendMessage, myControlz.hlvResults, LVM_SUBITEMHITTEST, 0, ADDR myLVHitTest
         .if eax != -1
            ;-----------------------------
            ; Transfer Item/SubItem values
            ;-----------------------------
            mov      eax, myLVHitTest.iItem
            mov      myLVItem.iItem, eax
            mov      eax, myLVHitTest.iSubItem
            mov      myLVItem.iSubItem, eax

            ;----------------------
            ; Get Item/SubItem Text
            ;----------------------
            mov      myLVItem.cchTextMax, 255
            mov      myLVItem.pszText, OFFSET stz_Temp1      ;TEXT BUFFER
            mov      myLVItem.imask, LVIF_TEXT
            invoke    SendMessage, myControlz.hlvResults, LVM_GETITEMTEXT, myLVItem.iItem, ADDR myLVItem

            ;-----------------------
            ; Prepare hidden EditBox
            ;-----------------------
            m2m      myRect.top, myLVItem.iSubItem
            mov      myRect.left, LVIR_BOUNDS
            Invoke   SendMessage, myControlz.hlvResults, LVM_GETSUBITEMRECT, myLVItem.iItem, ADDR myRect
            .if   eax != 0
               Invoke    SendMessage, myControlz.hedtLVCell, EM_SETRECT, NULL, ADDR myRect
               Invoke    SendMessage, myControlz.hedtLVCell, WM_SETTEXT, NULL, ADDR stz_Temp1

               mov      ebx, myRect.bottom
               sub      ebx, myRect.top
               add      myRect.top, 13         ;Add offset of invisible border

               ;------------------------------------------------------
               ; The Item (Column 0) Dx value includes the subitems ??
               ;------------------------------------------------------
               .if      myLVItem.iSubItem == 0
                  invoke   SendMessage, myControlz.hlvResults, LVM_GETCOLUMNWIDTH, 0, 0
                  .if eax != 0
                     add      myRect.left, 7   ;Add offset of invisible border
                     invoke   SetWindowPos, myControlz.hedtLVCell, HWND_TOP, myRect.left, myRect.top, eax, ebx, SWP_SHOWWINDOW
                  .endif
               .else
                     mov      eax, myRect.right
                     sub      eax, myRect.left
                     add      myRect.left, 7
                     invoke   SetWindowPos, myControlz.hedtLVCell, HWND_TOP, myRect.left, myRect.top, eax, ebx, SWP_SHOWWINDOW
               .endif                     
            .endif
         .endif
https://www.dropbox.com/s/7zr3yeitgnkzvc0/LView_SubItemEdit.jpg
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

dedndave


K_F

I'm going to tidy this thing up (add all the other functionality), and put it up as an example..
:)
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

Gunther

You have to know the facts before you can distort them.

K_F

Here an extended version of the ListView editing with an edit box.

I could go on forever.. but digressing would take too much time so I cut it at this point.
It's not perfect, but you might be able to use the idea..

It's an EasyCode project with the exe in the Debug folder.
8)
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'