[Class] LV_InCellEdit - update on 2015-12-15

Post your working scripts, libraries and tools for AHK v1.1 and older
Edd
Posts: 42
Joined: 16 Aug 2014, 16:45

Re: [Class] LV_InCellEdit - update on 2015-12-15

15 Dec 2015, 14:45

And so, I'll wait for the next release to update the library on my script! :D
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_InCellEdit - update on 2015-12-15

15 Dec 2015, 16:27

It has been released already! ;)
Edd
Posts: 42
Joined: 16 Aug 2014, 16:45

Re: [Class] LV_InCellEdit - update on 2015-12-15

15 Dec 2015, 19:45

Great! keep up the good work! :D
Edd
Posts: 42
Joined: 16 Aug 2014, 16:45

Re: [Class] LV_InCellEdit - update on 2015-12-15

29 Dec 2015, 20:24

Hello just me, I'm noticing that on my script using LV_InCellEdit sometimes the gui freezes and then I remember that you said this:
just me wrote: LV_InCellEdit() is a very time critical function which might cause the ListView or the whole Gui to freeze.
So my question is what can I do to avoid these freezes? , I noticed that when I change the focus of the gui to another window and return back again, the gui unfreeze it, is there a fix to this problem? I almost finish with my script but this situation that freezes the gui changes it all.. :cry:
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_InCellEdit - update on 2015-12-15

30 Dec 2015, 01:39

Unfortunately, I didn't find a work-around as yet. It seems to be related to AHK's processing of mouse click notifications, particularly left clicks, but I cannot even say which click at which time will produce the issue.
(See here).
Edd
Posts: 42
Joined: 16 Aug 2014, 16:45

Re: [Class] LV_InCellEdit - update on 2015-12-15

13 Jan 2016, 02:49

Hello just me, I noticed that when I send text to the edit cell via: Send, SendInput, etc the edit field moves all way to the left, is there a way to fix this? Thank you.
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_InCellEdit - update on 2015-12-15

13 Jan 2016, 04:37

I guess it has the same reason as the 'fast typing' issue. Some EN_UPDATE notification is passed directly to the ListView which will reposition the edit control in this case. If my last changes do not prevent the issue, I see no other option as yet.
Edd
Posts: 42
Joined: 16 Aug 2014, 16:45

Re: [Class] LV_InCellEdit - update on 2015-12-15

13 Jan 2016, 04:50

Well, maybe later you could find a solution I guess, the thing is that I'm using hotstrings to replace vocals with accents like "!a::á" something like that, but with that issue it won't work as desired. But anyways, thank you for the support, just me.
User avatar
kczx3
Posts: 1649
Joined: 06 Oct 2015, 21:39

Re: [Class] LV_InCellEdit - update on 2015-12-15

22 Mar 2016, 14:57

What would be the best way to update this class to account for if the cell has a subitem image set? I included LV_EX.ahk and updated the LVN_BEGINLABELEDIT function like so:

Code: Select all

   ; -------------------------------------------------------------------------------------------------------------------
   ; LVN_BEGINLABELEDIT notification
   ; -------------------------------------------------------------------------------------------------------------------
   LVN_BEGINLABELEDIT(L) {
      Static Indent := 4   ; indent of the Edit control, 4 seems to be reasonable for XP, Vista, and 7
      If (This.Item = -1) || (This.SubItem = -1)
         Return True
      H := This.HWND
      SendMessage, 0x1018, 0, 0, , % "ahk_id " . H ; LVM_GETEDITCONTROL
      This.HEDIT := ErrorLevel
      , VarSetCapacity(ItemText, 2048, 0) ; text buffer
      , VarSetCapacity(LVITEM, 40 + (A_PtrSize * 5), 0) ; LVITEM structure
      , NumPut(This.Item, LVITEM, 4, "Int")
      , NumPut(This.SubItem, LVITEM, 8, "Int")
      , NumPut(&ItemText, LVITEM, 16 + A_PtrSize, "Ptr") ; pszText in LVITEM
      , NumPut(1024 + 1, LVITEM, 16 + (A_PtrSize * 2), "Int") ; cchTextMax in LVITEM
      SendMessage, % (A_IsUnicode ? 0x1073 : 0x102D), % This.Item, % &LVITEM, , % "ahk_id " . H ; LVM_GETITEMTEXT
      This.ItemText := StrGet(&ItemText, ErrorLevel)
      ; Call the user function, if any
      If (This.EditUserFunc)
         This.EditUserFunc.Call("BEGIN", This.HWND, This.HEDIT, This.Item + 1, This.Subitem + 1, This.ItemText)
      ControlSetText, , % This.ItemText, % "ahk_id " . This.HEDIT
      If (This.SubItem > 0) && (This.Blank) {
         Empty := ""
         , NumPut(&Empty, LVITEM, 16 + A_PtrSize, "Ptr") ; pszText in LVITEM
         , NumPut(0,LVITEM, 16 + (A_PtrSize * 2), "Int") ; cchTextMax in LVITEM
         SendMessage, % (A_IsUnicode ? 0x1074 : 0x102E), % This.Item, % &LVITEM, , % "ahk_id " . H ; LVM_SETITEMTEXT
      }
      VarSetCapacity(RECT, 16, 0)
	 , NumPut(1, RECT, 0, "Int")
      , NumPut(This.SubItem, RECT, 4, "Int")
      SendMessage, 0x1038, This.Item, &RECT, , % "ahk_id " . H ; LVM_GETSUBITEMRECT
	 cellCoords := LV_EX_GetSubItemRect(This.HWND, This.SubItem, This.Item, 1)
      This.EX := NumGet(RECT, 0, "Int") + This.LX + This.DX + Indent + cellCoords.W
      , This.EY := NumGet(RECT, 4, "Int") + This.LY + This.DY
      If (This.OSVersion < 6)
         This.EY -= 1 ; subtract 1 for WinXP
      If (This.SubItem = 0) {
         SendMessage, 0x101D, 0, 0, , % "ahk_id " . H ; LVM_GETCOLUMNWIDTH
         This.EW := ErrorLevel
      }
      Else
         This.EW := NumGet(RECT, 8, "Int") - NumGet(RECT, 0, "Int")
      This.EW -= Indent
      , This.EH := NumGet(RECT, 12, "Int") - NumGet(RECT, 4, "Int")
      ; Register WM_COMMAND handler
      , This.CommandFunc := ObjBindMethod(This, "On_WM_COMMAND")
      , OnMessage(0x0111, This.CommandFunc)
      ; Register hotkeys
      If !(This.Next)
         This.RegisterHotkeys()
      This.Cancelled := False
      This.Next := False
      Return False
   }
This moved the edit field over to the right so the image isn't blocked (though IDK how this would effect a listview without subitem images). I also want the edit to span all the way over to the right edge of the cell but I'm not sure how to modify This.EW to achieve that either.
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_InCellEdit - update on 2015-12-15

24 Mar 2016, 01:45

Hi kczx3!

As far as I can see you made three changes to LVN_BEGINLABELEDIT():

Code: Select all

      VarSetCapacity(RECT, 16, 0)
	 , NumPut(1, RECT, 0, "Int") ; <<<<<<<<<< added
      , NumPut(This.SubItem, RECT, 4, "Int")
      SendMessage, 0x1038, This.Item, &RECT, , % "ahk_id " . H ; LVM_GETSUBITEMRECT
	 cellCoords := LV_EX_GetSubItemRect(This.HWND, This.SubItem, This.Item, 1) ; <<<<<<<<<< added
      This.EX := NumGet(RECT, 0, "Int") + This.LX + This.DX + Indent + cellCoords.W ; <<<<<<<<<< changed
The first change causes the LVM_GETSUBITEMRECT messages to retrieve the bounding rectangle of the icon or small icon instead of the the bounding rectangle of the entire item (LVIR_ICON = 1). The same rectangle will be retrieved by the added LV_EX_GetSubItemRect() call (param 4 = 1). Why do you want to get the same rectangle twice?
...(though IDK how this would effect a listview without subitem images)
How about a quick test? ;)
I also want the edit to span all the way over to the right edge of the cell ...
LV_InCellEdit() tries to mimic the default behaviour of the built-in edit control. So the width of the edit depends on its content. This is implemented in On_WM_COMMAND() using the LVM_GETSTRINGWIDTH message (0x1011 / 0x1057).
canisdibellum
Posts: 47
Joined: 09 Oct 2014, 11:44

Re: [Class] LV_InCellEdit - update on 2015-12-15

12 Jul 2016, 02:26

Sorry didnt have time to read other comments....implemented your code and loved it but had to
Remove it for 2 reasons...1) it had a tendency to add a leading space and 2) you can no longer use controlget to get mass data from LVs
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_InCellEdit - update on 2015-12-15

12 Jul 2016, 04:42

Hi canisdibellum.

I'm not sure what you are talking about.
1) it had a tendency to add a leading space
I never noticed such an issue and nobody else reported it as yet.
2) you can no longer use controlget to get mass data from LVs
What do you mean? The class is using ControlGet internally without any known problems.
canisdibellum
Posts: 47
Joined: 09 Oct 2014, 11:44

Re: [Class] LV_InCellEdit - update on 2015-12-15

12 Jul 2016, 07:37

just me wrote:Hi canisdibellum.

I'm not sure what you are talking about.
1) it had a tendency to add a leading space
I never noticed such an issue and nobody else reported it as yet.
2) you can no longer use controlget to get mass data from LVs
What do you mean? The class is using ControlGet internally without any known problems.
1. Literally.....I can't remember if it was cells that were created as "blank" (it would make sense that if a cell held no data from an lv_add that it would populate w/ a space and i didnt think to look for it) or if it was just edited cells that developed the leading space.....i had to go and manually fix a lot of instances where the cells had a space before the data.

2. It looks like your script uses some sort of transparent overlay over the lv.....try to use the windowspy built in to scite to determine the classnn and you will see what i mean...and using classnn that worked before implementation doesnt work either

The gui i was using this with had 4 tab3 tabs each with a massive LV on each and i only implemented on the one on the second tab. When i would use controlget the outputvar would be blank no matter what and when i used windowspy to figure out if the class nn changed or something i couldn't get a listview nn at all from any of my lvs.
Note: ControlGet and retrieving the classnn worked before implementing your script and started working again once i removed the last remnant.
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_InCellEdit - update on 2015-12-15

12 Jul 2016, 15:24

1. Literally.....I can't remember if it was cells that were created as "blank" (it would make sense that if a cell held no data from an lv_add that it would populate w/ a space and i didnt think to look for it) or if it was just edited cells that developed the leading space.....i had to go and manually fix a lot of instances where the cells had a space before the data.
Well I will check it.
canisdibellum wrote:2. It looks like your script uses some sort of transparent overlay over the lv.....try to use the windowspy built in to scite to determine the classnn and you will see what i mean...and using classnn that worked before implementation doesnt work either.
The class doesn't use 'some sort of transparent overlay'. But the Tab3 control might behave so. Why don't you use the HWND instead of the ClassNN?
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_InCellEdit - update on 2015-12-15

13 Jul 2016, 03:26

I wrote:
1. Literally.....I can't remember if it was cells that were created as "blank" (it would make sense that if a cell held no data from an lv_add that it would populate w/ a space and i didnt think to look for it) or if it was just edited cells that developed the leading space.....i had to go and manually fix a lot of instances where the cells had a space before the data.
Well I will check it.
Well I did some tests but wasn't able to reproduce the issue.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Gewerd_Strauss, Google [Bot] and 218 guests