Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Solved] G-Label performing action in another ListView



  • Please log in to reply
2 replies to this topic
over21
  • Members
  • 33 posts
  • Last active: Jul 30 2014 01:45 PM
  • Joined: 09 Mar 2010
I want a second listview in my Gui to receive input (via LV_Insert/LV_Modify) when I click a column header to sort the rows in my first listview. I have the following Gui:

Gui, Add, ListView, r20 w700 gLabel, val1|val2|val3
LV_Insert(1, "", 40, 20, 10)
LV_Insert(2, "", 8, 3, 2)
LV_Insert(3, "", 2, 1, 0)
Gui, Add, ListView, r20 w100 x+20, Difference:

gLabel:
if A_GuiEvent = ColClick
Loop % LV_GetCount()
{
  LV_GetText(ValVar, A_Index, A_EventInfo)
  diffVal=ValVar-ValVarMemo
  LV_Insert(A_Index, "", diffVal) ; this I want performed on the second listview (not on the one that executes the GLabel)
  ValVarMemo=ValVar
}
For instance, if I sort the column "val2" (contaning: "8", "3", "2") in the the second listview I want to receive in order: "" (blank row) followed by "5" (8-3) and "1" (3-2). Is it possible?

Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
✓  Best Answer
Use Gui, ListView, ListViewName to set the listview to work upon by it's variable name.
Gui, Add, ListView, r20 w700 gLabel [color=#FF0000]vLV1[/color], val1|val2|val3
LV_Insert(1, "", 40, 20, 10)
LV_Insert(2, "", 8, 3, 2)
LV_Insert(3, "", 2, 1, 0)
Gui, Add, ListView, r20 w100 x+20 [color=#0000FF]vLV2[/color], Difference:
Gui, Show
return

Label:
if A_GuiEvent = ColClick
Loop % LV_GetCount()
{
  [color=#FF0000]Gui, ListView, LV1[/color]
  LV_GetText(ValVar, A_Index, A_EventInfo)
  diffVal:=ValVar-ValVarMemo
  [color=#0000FF]Gui, ListView, LV2[/color]
  LV_Insert(A_Index, "", diffVal) ; this I want performed on the second listview (not on the one that executes the GLabel)
  ValVarMemo:=ValVar
}
[color=#FF0000]Gui, ListView, LV1[/color]
return
And don't forget you to use := for the calculations, not =.

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


over21
  • Members
  • 33 posts
  • Last active: Jul 30 2014 01:45 PM
  • Joined: 09 Mar 2010
Thanks, this is exactly what I neeed. The final version of the script looks like this:

Main:
if (A_GuiEvent = "ColClick")
{
  Gui, ListView, Diff
  LV_Delete()

  if (A_EventInfo <> "1")
  {
    diffVar:="0"
    diffVarMemo:="0"
    emptyVar:=""
    Gui, ListView, Main
    Loop % LV_GetCount()
    {
      Gui, ListView, Main ; not redundant, the loop ends with focus on Diff ListView
      LV_GetText(diffVar, A_Index, A_EventInfo)
      numberVar := diffVar ; not redundant, the number is returned as text by LV_GetText
      numberVar := numberVar - diffVarMemo
      diffVarMemo := diffVar
      Gui, ListView, Diff
      if (A_Index = "1")
        LV_Insert(1, "", emptyVar) ; the first row is blank ; any text/number can be added here
      else
        LV_Insert(A_Index, "", numberVar)
    }
  }
}
Return