ListViewGetContent with option "Col4" fails with Column 1 (displays Col1 and Col2 in test code)
Issue #62
closed
Issue
ListViewGetContent has 7 options. Option styled “Col4” in the docs [per docs replace '4' with desired #] fails if Col 1 is selected.
steps to duplicate
Run code below with Keysharp.
MyGui := Gui()
LV2_Label := MyGui.Add("Text", "w400 x10 y10","ListView testing")
LV2_Label.SetFont("cBlue s10")
; Create the ListView with two columns, Name and Size:
LV2 := MyGui.Add("ListView", "r15 w350 x10 y+5", ["Name","Size (KB)"])
Loop Files, A_MyDocuments "\*.*"
LV2.Add(, A_LoopFileName, A_LoopFileSizeKB)
LV2_Btn3 := MyGui.Add("Button", "x10 y+10", "Column 1")
LV2_Btn3.OnEvent("Click", "LV_Col1")
MyGui.Show()
LV_Col1() {
List := ListViewGetContent("Col1", LV2, MyGui)
MsgBox(List, "LV Column 1")
List := ""
}
Note that both Col1 and Col2 are displayed. (Replace “Col1” with “Col2” in Line 21 to see no failure if Col2 is selected).
AHk verification code
MyGui := Gui()
LV2_Label := MyGui.Add("Text", "w400 x10 y10","ListView testing")
LV2_Label.SetFont("cBlue s10")
; Create the ListView with two columns, Name and Size:
LV2 := MyGui.Add("ListView", "r15 w350 x10 y+5", ["Name","Size (KB)"])
Loop Files, A_MyDocuments "\*.*"
LV2.Add(, A_LoopFileName, A_LoopFileSizeKB)
LV2_Btn3 := MyGui.Add("Button", "x10 y+10", "Column 1")
LV2_Btn3.OnEvent("Click", LV_Col1)
MyGui.Show()
LV_Col1(*) {
List := ListViewGetContent("Col1", LV2, MyGui)
MsgBox(List, "LV Column 1")
List := ""
}
Comments (6)
-
reporter -
reporter It may be that a starting point would be line 954 in Keysharp.Core.Windows.ControlManager:
else if (Options.TryParse(opt, "col", ref col)) { col--; }
If ‘col’ == 1, then after operation col would be 0, if I’m not mistaken, and all columns would be shown.
-
repo owner Committed a fix, please test.
-
reporter Fixed following latest commit, thank you. Marking resolved and closing.
-
reporter - changed status to resolved
Resolved.
-
reporter - changed status to closed
Closed.
- Log in to comment
I ran dnSpy on Keysharp to try to find the code for “Count Col”. Examining the source code of Keysharp.Core.Windows.ControlManager, I’ve been unable to find the code that resulted in this listing from dnSpy:
However, if this is an accurate representation of what the code is doing, it appears that if ‘col’ is equal to 1, then col2 will also equal 1. ‘col’ is then assigned col2-1, or 1-1, or 0, resulting in a display of all columns, which is the failure with number of columns set to '1'.