@just me:
Just googled it. Found this thread: https://autohotkey.com/board/topic/84333-class-class-scrollguiahk-simply-scroll-your-guis/
And that one is created by you. Still struggling to understand what I should do that in order to make use of that.
[solved] How to make my simple GUI window scrollable? Topic is solved
Re: [solved] How to make my simple GUI window scrollable?
Last edited by Benny-D on 11 Feb 2020, 09:50, edited 1 time in total.
Re: [solved] How to make my simple GUI window scrollable?
It’s generally helpful to prefix your search in google with ahk or github. Here is the source for the class - https://github.com/AHK-just-me/Class_ScrollGUI
Re: [solved] How to make my simple GUI window scrollable?
@kczx3,
What should I do there? I clicked on "Sources" and then on "Class_ScrollGUI.ahk", so eventually I landed here:
https://github.com/AHK-just-me/Class_ScrollGUI/blob/master/Sources/Class_ScrollGUI.ahk
Is it the script I am supposed to be after? It is almost 6 times bigger than the script that you gave me! Is it really practical to use such a big script? Besides, how do I get it? By highlighting it and then copying it? I don't see any download button there. What are those "Blame" and "Raw" buttons?
What should I do there? I clicked on "Sources" and then on "Class_ScrollGUI.ahk", so eventually I landed here:
https://github.com/AHK-just-me/Class_ScrollGUI/blob/master/Sources/Class_ScrollGUI.ahk
Is it the script I am supposed to be after? It is almost 6 times bigger than the script that you gave me! Is it really practical to use such a big script? Besides, how do I get it? By highlighting it and then copying it? I don't see any download button there. What are those "Blame" and "Raw" buttons?
-
- Posts: 143
- Joined: 25 Dec 2020, 12:26
Re: [solved] How to make my simple GUI window scrollable?
i added some codes to the script (original from lexikos, i supposed) so that it can respond to touch gesture scrolling.
*** 2021sep20 script updated
*** 2021sep20 script updated
Code: Select all
gui, +resize
loop, 99
{ s := a_index ":" a_space
loop, 99
s .= a_index a_space
t .= s "`n"
gui, add, text,, % s
}
gui, add, edit, w600 h600 hscroll, % t
w := A_ScreenWidth - 50, h := A_ScreenHeight - 100
gui, show, w%w% h%h%
onmessage(0x115, "onscroll") ; WM_VSCROLL
onmessage(0x114, "onscroll") ; WM_HSCROLL
onmessage(0x20a, "onscroll") ; WM_MOUSEWHEEL
onmessage(0x20e, "onscroll") ; WM_MOUSEHWHEEL
onmessage(0x119, "gHandler") ; WM_GESTURE
return
guisize:
UpdateScrollBars(A_Gui, A_GuiWidth, A_GuiHeight)
return
UpdateScrollBars(GuiNum, GuiWidth, GuiHeight) { ;written by lexikos
static SIF_RANGE=0x1, SIF_PAGE=0x2, SIF_DISABLENOSCROLL=0x8, SB_HORZ=0, SB_VERT=1
Gui, %GuiNum%:Default
Gui, +LastFound
; Calculate scrolling area.
Left := Top := 9999
Right := Bottom := 0
WinGet, ControlList, ControlList
Loop, Parse, ControlList, `n
{
GuiControlGet, c, Pos, %A_LoopField%
if (cX < Left)
Left := cX
if (cY < Top)
Top := cY
if (cX + cW > Right)
Right := cX + cW
if (cY + cH > Bottom)
Bottom := cY + cH
}
Left -= 8
Top -= 8
Right += 8
Bottom += 8
ScrollWidth := Right-Left
ScrollHeight := Bottom-Top
; Initialize SCROLLINFO.
VarSetCapacity(si, 28, 0)
NumPut(28, si) ; cbSize
NumPut(SIF_RANGE | SIF_PAGE, si, 4) ; fMask
; Update horizontal scroll bar.
NumPut(ScrollWidth, si, 12) ; nMax
NumPut(GuiWidth, si, 16) ; nPage
DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_HORZ, "uint", &si, "int", 1)
; Update vertical scroll bar.
; NumPut(SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL, si, 4) ; fMask
NumPut(ScrollHeight, si, 12) ; nMax
NumPut(GuiHeight, si, 16) ; nPage
DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_VERT, "uint", &si, "int", 1)
if (Left < 0 && Right < GuiWidth)
x := Abs(Left) > GuiWidth-Right ? GuiWidth-Right : Abs(Left)
if (Top < 0 && Bottom < GuiHeight)
y := Abs(Top) > GuiHeight-Bottom ? GuiHeight-Bottom : Abs(Top)
if (x || y)
DllCall("ScrollWindow", "uint", WinExist(), "int", x, "int", y, "uint", 0, "uint", 0)
}
OnScroll(wParam, lParam, msg, hwnd) { ;written by lexikos
static SIF_ALL=0x17, SCROLL_STEP=85 ;changed by SundayProgrammer from 10 to 85 for a more practical outcome
static xpos := 0, ypos := 0 ;added by SundayProgrammer - for touch gesture scrolling
global gFlag ;added by SundayProgrammer - for touch gesture scrolling
if DllCall("GetParent", "uint", hwnd) ;added by SundayProgrammer - a quick fix for the scenario when any scrollable control is involved
return ;added by SundayProgrammer - a quick fix for the scenario when any scrollable control is involved
bar := (msg=0x115) or (msg=0x20A) ; (SB_HORZ=0, SB_VERT=1) or (WM_MOUSEHWHEEL=0, WM_MOUSEWHEEL=1) ;changed by SundayProgrammer - for WM_MOUSEWHEEL and WM_MOUSEHWHEEL
if gFlag ;added by SundayProgrammer - for touch gesture scrolling
{ gAction(xpos, ypos, bar, hwnd) ;added by SundayProgrammer - for touch gesture scrolling
return ;added by SundayProgrammer - for touch gesture scrolling
} ;added by SundayProgrammer - for touch gesture scrolling
VarSetCapacity(si, 28, 0)
NumPut(28, si) ; cbSize
NumPut(SIF_ALL, si, 4) ; fMask
if !DllCall("GetScrollInfo", "uint", hwnd, "int", bar, "uint", &si)
return
VarSetCapacity(rect, 16)
DllCall("GetClientRect", "uint", hwnd, "uint", &rect)
new_pos := NumGet(si, 20) ; nPos (saw "25" in another version, which exhibited a bug in my testing, whereas "20" (this version) worked fine so far)
if msg=0x20A ;added by SundayProgrammer - for WM_MOUSEWHEEL
wParam := wParam>0x780000 ;added by SundayProgrammer - for WM_MOUSEWHEEL
else if msg=0x20E ;added by SundayProgrammer - for WM_MOUSEHWHEEL
wParam := wParam=0x780000 ;added by SundayProgrammer - for WM_MOUSEHWHEEL
action := wParam & 0xFFFF
if action = 0 ; SB_LINEUP
new_pos -= SCROLL_STEP
else if action = 1 ; SB_LINEDOWN
new_pos += SCROLL_STEP
else if action = 2 ; SB_PAGEUP
new_pos -= NumGet(rect, 12, "int") - SCROLL_STEP
else if action = 3 ; SB_PAGEDOWN
new_pos += NumGet(rect, 12, "int") - SCROLL_STEP
else if (action = 5 || action = 4) ; SB_THUMBTRACK || SB_THUMBPOSITION
new_pos := wParam>>16
else if action = 6 ; SB_TOP
new_pos := NumGet(si, 8, "int") ; nMin
else if action = 7 ; SB_BOTTOM
new_pos := NumGet(si, 12, "int") ; nMax
else
return
min := NumGet(si, 8, "int") ; nMin
max := NumGet(si, 12, "int") - NumGet(si, 16) ; nMax-nPage
new_pos := new_pos > max ? max : new_pos
new_pos := new_pos < min ? min : new_pos
old_pos := NumGet(si, 20, "int") ; nPos (saw "25" in another version, which exhibited a bug in my testing, whereas "20" (this version) worked fine so far)
x := y := 0
if bar = 0 ; SB_HORZ
x := old_pos-new_pos
else
y := old_pos-new_pos
; Scroll contents of window and invalidate uncovered area.
DllCall("ScrollWindow", "uint", hwnd, "int", x, "int", y, "uint", 0, "uint", 0)
; Update scroll bar.
NumPut(new_pos, si, 20, "int") ; nPos (saw "25" in another version, which exhibited a bug in my testing, whereas "20" (this version) worked fine so far)
DllCall("SetScrollInfo", "uint", hwnd, "int", bar, "uint", &si, "int", 1)
z := bar ? "y" : "x", %z%pos := new_pos ;added by SundayProgrammer - for touch gesture scrolling
}
gAction(byref xpos, byref ypos, bar, hwnd) { ;written by SundayProgrammer - for touch gesture scrolling
VarSetCapacity(si, 28, 0), NumPut(28, si), NumPut(0x17, si, 4), DllCall("GetScrollInfo", "uint", hwnd, "int", bar, "uint", &si), aPos := NumGet(si, 20, "int"), z := bar ? "y" : "x"
if not (%z%pos = aPos)
x := y := 0, %z% := %z%pos - aPos, DllCall("ScrollWindow", "uint", hwnd, "int", x, "int", y, "uint", 0, "uint", 0), %z%pos := aPos
}
gHandler(wParam, lParam, msg, hwnd) { ;written by SundayProgrammer - for touch gesture scrolling
global gFlag
gFlag := true
settimer, Reset_gFlag, -100
return
Reset_gFlag:
gFlag := false
return
}
Last edited by SundayProgrammer on 24 Sep 2021, 18:16, edited 2 times in total.
Re: [solved] How to make my simple GUI window scrollable?
- Thank you! But why when I drag down the vertical scroller (I don't know what to call it correctly) and let go of it, it jumps back to the upmost position? It only stays at the bottom when I let go of it after dragging it all the way down. There is no such problem with the horizontal scroller.SundayProgrammer wrote: ↑18 Sep 2021, 04:11i added some codes to the script (original from lexikos, i supposed) so that it can respond to touch gesture scrolling.
-
- Posts: 143
- Joined: 25 Dec 2020, 12:26
Re: [solved] How to make my simple GUI window scrollable?
i've no idea, as there is no such problem over here. would you mind to test it in one/some more system (different hardware and/or software) to see if it persists?Benny-D wrote: ↑19 Sep 2021, 18:56- Thank you! But why when I drag down the vertical scroller (I don't know what to call it correctly) and let go of it, it jumps back to the upmost position? It only stays at the bottom when I let go of it after dragging it all the way down. There is no such problem with the horizontal scroller.SundayProgrammer wrote: ↑18 Sep 2021, 04:11i added some codes to the script (original from lexikos, i supposed) so that it can respond to touch gesture scrolling.
-
- Posts: 143
- Joined: 25 Dec 2020, 12:26
Re: [solved] How to make my simple GUI window scrollable?
found a bug which occurs only when any scrollable control is involved. and i end up added four lines of code to fix it.
and to make these four lines a bit outstanding, i've left them in awkward indentation.
the script is updated.
and to make these four lines a bit outstanding, i've left them in awkward indentation.
the script is updated.
Re: [solved] How to make my simple GUI window scrollable?
- Thank you for your work. I tried your updated script. The problem is still there. I think it's a problem with my computer. I'll try it on another one when I have a chance.SundayProgrammer wrote: ↑20 Sep 2021, 09:14found a bug which occurs only when any scrollable control is involved. and i end up added four lines of code to fix it.
-
- Posts: 143
- Joined: 25 Dec 2020, 12:26
Re: [solved] How to make my simple GUI window scrollable?
i've just realized that the bug "when any scrollable control is involved, the screen got messed up" was not because of the codes i added for touch gesture scrolling. it was always working like that.
so, i've changed the fix to cover everything instead of for my added part only. which made it even more simple, it's now just two lines of code instead of four.
the script is updated.
so, i've changed the fix to cover everything instead of for my added part only. which made it even more simple, it's now just two lines of code instead of four.
the script is updated.
Re: [solved] How to make my simple GUI window scrollable?
- So there is no way of getting rid of that problem? TBH, it's quite annoying, especially when you work with other non-AHK scrollable windows (like when you open MS Word, Notepad, or any browser windows) and see how perfect they are in terms of scrolling.