So I've come across this problem. With the script immediately below, the listview scrolls endlessly if you click on the empty space below or above the scrollbar. So for example, try the following:
-Run the script
-Don't press any buttons or do anything- just proceed to the step below:
-Hover the cursor just above the 'down' arrow in the scrollbar column on the right side of the gui
-left-click once
-the scrollbar will continuously scroll downwards until it hits the bottom
-and then if you immediately click just below the 'up' arrow, the scrollbar will scroll repeatedly upwards until it hits the top... and so on
..the problem is, it should only scroll down one time. But it is scrolling down repeatedly until it gets to the bottom or top of the listview for some reason.
Here's the code:
Code: Select all
Gui, Add, Button, x0 y0 w70 h21, BUTTON1
Gui, Add, Button, x75 y0 w70 h21, BUTTON2
Gui, Add, Button, x150 y0 w70 h21, BUTTON3
Gui, Add, ListView, Altsubmit x0 y25 r15 w700 h350 gMyListView, Checkbox|Brush Name (KB)
LV_Add(1,"BRUSH 1")
LV_Add(1,"BRUSH 2")
LV_Add(1,"BRUSH 3")
LV_Add(1,"BRUSH 4")
LV_Add(1,"BRUSH 5")
LV_Add(1,"BRUSH 6")
LV_Add(1,"BRUSH 7")
LV_Add(1,"BRUSH 8")
LV_Add(1,"BRUSH 9")
LV_Add(1,"BRUSH 10")
LV_Add(1,"BRUSH 11")
LV_Add(1,"BRUSH 12")
LV_Add(1,"BRUSH 13")
LV_Add(1,"BRUSH 14")
LV_Add(1,"BRUSH 15")
LV_Add(1,"BRUSH 16")
LV_Add(1,"BRUSH 17")
LV_Add(1,"BRUSH 18")
LV_Add(1,"BRUSH 19")
LV_Add(1,"BRUSH 20")
LV_Add(1,"BRUSH 21")
LV_Add(1,"BRUSH 22")
LV_Add(1,"BRUSH 23")
LV_Add(1,"BRUSH 24")
LV_Add(1,"BRUSH 25")
LV_Add(1,"BRUSH 26")
LV_Add(1,"BRUSH 27")
LV_Add(1,"BRUSH 28")
LV_Add(1,"BRUSH 29")
LV_Add(1,"BRUSH 30")
LV_Add(1,"BRUSH 31")
LV_Add(1,"BRUSH 32")
LV_Add(1,"BRUSH 33")
LV_Add(1,"BRUSH 34")
LV_Add(1,"BRUSH 35")
LV_Add(1,"BRUSH 36")
LV_Add(1,"BRUSH 37")
LV_Add(1,"BRUSH 38")
LV_Add(1,"BRUSH 39")
LV_Add(1,"BRUSH 40")
LV_Add(1,"BRUSH 41")
LV_Add(1,"BRUSH 42")
LV_Add(1,"BRUSH 43")
LV_Add(1,"BRUSH 44")
LV_Add(1,"BRUSH 45")
LV_Add(1,"BRUSH 46")
LV_Add(1,"BRUSH 47")
LV_Add(1,"BRUSH 48")
LV_Add(1,"BRUSH 49")
LV_Add(1,"BRUSH 50")
LV_Add(1,"BRUSH 51")
LV_Add(1,"BRUSH 52")
LV_Add(1,"BRUSH 53")
LV_Add(1,"BRUSH 54")
LV_Add(1,"BRUSH 55")
LV_Add(1,"BRUSH 56")
LV_Add(1,"BRUSH 57")
LV_Add(1,"BRUSH 58")
LV_Add(1,"BRUSH 59")
LV_Add(1,"BRUSH 60")
LV_Add(1,"BRUSH 61")
LV_Add(1,"BRUSH 62")
LV_Add(1,"BRUSH 63")
LV_Add(1,"BRUSH 64")
LV_Add(1,"BRUSH 65")
LV_Add(1,"BRUSH 66")
LV_Add(1,"BRUSH 67")
LV_Add(1,"BRUSH 68")
LV_Add(1,"BRUSH 69")
LV_Add(1,"BRUSH 70")
LV_Add(1,"BRUSH 71")
LV_Add(1,"BRUSH 72")
LV_Add(1,"BRUSH 73")
LV_Add(1,"BRUSH 74")
LV_Add(1,"BRUSH 75")
LV_Add(1,"BRUSH 76")
LV_Add(1,"BRUSH 77")
LV_Add(1,"BRUSH 78")
LV_Add(1,"BRUSH 79")
LV_Add(1,"BRUSH 80")
LV_ModifyCol() ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer") ; For sorting purposes, indicate that column 2 is an integer.
Gui, Show
return
MyListView:
if A_GuiEvent = Normal ;this is the same as a left click
{
LV_GetText(RowText, A_EventInfo) ; Get the text from the row's first field.
ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%"
}
return
GuiClose:
ExitApp
ButtonBUTTON1:
msgbox, BUTTON1
Return
ButtonBUTTON2:
msgbox, BUTTON2
Return
ButtonBUTTON3:
msgbox, BUTTON3
Return
However... if I alter the code and move the "Gui, Add, Button" lines down to underneath the "LV_Add" portions, then this problem stops. Here's the updated code for that:
Code: Select all
Gui, Add, ListView, Altsubmit x0 y25 r15 w700 h350 gMyListView, Checkbox|Brush Name (KB)
LV_Add(1,"BRUSH 1")
LV_Add(1,"BRUSH 2")
LV_Add(1,"BRUSH 3")
LV_Add(1,"BRUSH 4")
LV_Add(1,"BRUSH 5")
LV_Add(1,"BRUSH 6")
LV_Add(1,"BRUSH 7")
LV_Add(1,"BRUSH 8")
LV_Add(1,"BRUSH 9")
LV_Add(1,"BRUSH 10")
LV_Add(1,"BRUSH 11")
LV_Add(1,"BRUSH 12")
LV_Add(1,"BRUSH 13")
LV_Add(1,"BRUSH 14")
LV_Add(1,"BRUSH 15")
LV_Add(1,"BRUSH 16")
LV_Add(1,"BRUSH 17")
LV_Add(1,"BRUSH 18")
LV_Add(1,"BRUSH 19")
LV_Add(1,"BRUSH 20")
LV_Add(1,"BRUSH 21")
LV_Add(1,"BRUSH 22")
LV_Add(1,"BRUSH 23")
LV_Add(1,"BRUSH 24")
LV_Add(1,"BRUSH 25")
LV_Add(1,"BRUSH 26")
LV_Add(1,"BRUSH 27")
LV_Add(1,"BRUSH 28")
LV_Add(1,"BRUSH 29")
LV_Add(1,"BRUSH 30")
LV_Add(1,"BRUSH 31")
LV_Add(1,"BRUSH 32")
LV_Add(1,"BRUSH 33")
LV_Add(1,"BRUSH 34")
LV_Add(1,"BRUSH 35")
LV_Add(1,"BRUSH 36")
LV_Add(1,"BRUSH 37")
LV_Add(1,"BRUSH 38")
LV_Add(1,"BRUSH 39")
LV_Add(1,"BRUSH 40")
LV_Add(1,"BRUSH 41")
LV_Add(1,"BRUSH 42")
LV_Add(1,"BRUSH 43")
LV_Add(1,"BRUSH 44")
LV_Add(1,"BRUSH 45")
LV_Add(1,"BRUSH 46")
LV_Add(1,"BRUSH 47")
LV_Add(1,"BRUSH 48")
LV_Add(1,"BRUSH 49")
LV_Add(1,"BRUSH 50")
LV_Add(1,"BRUSH 51")
LV_Add(1,"BRUSH 52")
LV_Add(1,"BRUSH 53")
LV_Add(1,"BRUSH 54")
LV_Add(1,"BRUSH 55")
LV_Add(1,"BRUSH 56")
LV_Add(1,"BRUSH 57")
LV_Add(1,"BRUSH 58")
LV_Add(1,"BRUSH 59")
LV_Add(1,"BRUSH 60")
LV_Add(1,"BRUSH 61")
LV_Add(1,"BRUSH 62")
LV_Add(1,"BRUSH 63")
LV_Add(1,"BRUSH 64")
LV_Add(1,"BRUSH 65")
LV_Add(1,"BRUSH 66")
LV_Add(1,"BRUSH 67")
LV_Add(1,"BRUSH 68")
LV_Add(1,"BRUSH 69")
LV_Add(1,"BRUSH 70")
LV_Add(1,"BRUSH 71")
LV_Add(1,"BRUSH 72")
LV_Add(1,"BRUSH 73")
LV_Add(1,"BRUSH 74")
LV_Add(1,"BRUSH 75")
LV_Add(1,"BRUSH 76")
LV_Add(1,"BRUSH 77")
LV_Add(1,"BRUSH 78")
LV_Add(1,"BRUSH 79")
LV_Add(1,"BRUSH 80")
Gui, Add, Button, x0 y0 w70 h21, BUTTON1
Gui, Add, Button, x75 y0 w70 h21, BUTTON2
Gui, Add, Button, x150 y0 w70 h21, BUTTON3
LV_ModifyCol() ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer") ; For sorting purposes, indicate that column 2 is an integer.
Gui, Show
return
MyListView:
if A_GuiEvent = Normal ;this is the same as a left click
{
LV_GetText(RowText, A_EventInfo) ; Get the text from the row's first field.
ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%"
}
return
GuiClose:
ExitApp
ButtonBUTTON1:
msgbox, BUTTON1
Return
ButtonBUTTON2:
msgbox, BUTTON2
Return
ButtonBUTTON3:
msgbox, BUTTON3
Return
Just for argument's sake, why is the placement of adding the buttons in the code causing the scrolling problem?