The MASM Forum

General => The Workshop => Topic started by: K_F on October 24, 2013, 02:30:39 AM

Title: ListView subitem editing
Post by: K_F on October 24, 2013, 02:30:39 AM
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

Title: Re: ListView subitem editing
Post by: Tedd on October 24, 2013, 02:57:48 AM
Send LVM_EDITLABEL to the listview control ;)

http://msdn.microsoft.com/en-us/library/windows/desktop/bb774898%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/bb774898%28v=vs.85%29.aspx)
Title: Re: ListView subitem editing
Post by: K_F on October 24, 2013, 04:31:10 AM
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.
Title: Re: ListView subitem editing
Post by: fearless on October 24, 2013, 09:02:03 AM
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.
Title: Re: ListView subitem editing
Post by: K_F on October 24, 2013, 05:40:02 PM
Thanks Fearless.. I think that looks similar to what I'm thinking... I read through it  :t
Title: Re: ListView subitem editing = Who Dunnit!!
Post by: K_F on October 24, 2013, 09:21:47 PM
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 (https://www.dropbox.com/s/7zr3yeitgnkzvc0/LView_SubItemEdit.jpg)
Title: Re: ListView subitem editing
Post by: dedndave on October 24, 2013, 11:09:49 PM
tricky   :t
Title: Re: ListView subitem editing
Post by: K_F on October 25, 2013, 06:15:37 AM
I'm going to tidy this thing up (add all the other functionality), and put it up as an example..
:)
Title: Re: ListView subitem editing
Post by: Gunther on October 25, 2013, 07:01:07 AM
K_F,

well done.  :t

Gunther
Title: Re: ListView subitem editing
Post by: K_F on November 19, 2013, 05:30:02 PM
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)