Listview Add Buttons problem?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scriptor2016
Posts: 863
Joined: 21 Dec 2015, 02:34

Listview Add Buttons problem?

Post by scriptor2016 » 23 Jan 2022, 04:55

Greetings to all on this fine late night

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?

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Listview Add Buttons problem?

Post by swagfag » 23 Jan 2022, 05:11

Image
i dont see anything wrong

scriptor2016
Posts: 863
Joined: 21 Dec 2015, 02:34

Re: Listview Add Buttons problem?

Post by scriptor2016 » 23 Jan 2022, 05:17

Hmm. Strange. I even closed all other scripts and I'm still getting this problem.

I'm on Win7 64 bit. I'm wondering if that might be an issue.

scriptor2016
Posts: 863
Joined: 21 Dec 2015, 02:34

Re: Listview Add Buttons problem?

Post by scriptor2016 » 23 Jan 2022, 05:32

Man, this is odd. The top script posted above causes a problem on my end, but the bottom script acts normally.

If I run the top script, this is the sequence that causes the problem:

-Run the script
-Hover the cursor into an empty space in scrollbar column - and now the 'up' and 'down' arrows should become visually highlighted/activated (they become darker)
-Left click once, and the scrollbar repeatedly scrolls towards the cursor placement. (Try and click well above or below the scrollbar's current position so it has space to scroll repeatedly)
-Now, the 'up' and 'down' arrows have become de-highlighted
-So again, we must click on an empty space in the scrollbar column, so that the 'up' and 'down' arrows are once again highlighted/active(darker in color)
-Click again in the same spot, and the scrollbar will repeatedly scroll again

Sorry I can't explain this better lol. Hopefully someone will run across this same issue. The bottom script works, however. Just by changing the placement of adding the buttons. It's for sure an issue with adding the buttons, because if I remove the buttons altogether then this problem disappears. Sorry I don't have video capabilities to demonstrate.
Last edited by scriptor2016 on 23 Jan 2022, 05:36, edited 1 time in total.

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Listview Add Buttons problem?

Post by swagfag » 23 Jan 2022, 05:33

i dont know. i dont have windows7

scriptor2016
Posts: 863
Joined: 21 Dec 2015, 02:34

Re: Listview Add Buttons problem?

Post by scriptor2016 » 23 Jan 2022, 05:37

no worries haha.

But this is an issue I really can't figure out... maybe someone with Win7 might be able to chime in at some point. Cheers :D

Post Reply

Return to “Ask for Help (v1)”