OK, I fixed scrolling for multiple windows, but Mouse Wheel scrolling is currently broken for multiple windows.
Compiled demo: http://evilc.com/files/tmp/scrollbars.exe
Class_ScrollGUI - updated on 2015-03-13
Re: Class_ScrollGUI - updated on 2015-02-13
Great work! And it's so easy to use it!
I just added this feature to the settings window in AutoHotFlow.
There seems to be a bug. When adding only one of the scroll bars, the gui has wrong size:
The size becomes correct after resizing the window manually.
This is the code I use. T o see all details you may download AutoHotFlow and you'll find the code in "Editor\User Interface\ui_Element_Settings.ahk".
I just added this feature to the settings window in AutoHotFlow.
There seems to be a bug. When adding only one of the scroll bars, the gui has wrong size:
The size becomes correct after resizing the window manually.
This is the code I use. T o see all details you may download AutoHotFlow and you'll find the code in "Editor\User Interface\ui_Element_Settings.ahk".
Code: Select all
gui -hwndSettingWindowHWND
SG2 := New ScrollGUI(SettingWindowHWND,600, A_ScreenHeight*0.8, "+LabelGui2 +Resize +MinSize420x100 ",2)
SG2.Show(lang("Settings") " - " lang(%ElementID%type) " - " lang(%ElementID%subtype), "xCenter yCenter")
Scripting is too complicated? Try AutoHotFlow, the graphical automation tool! Written in AutoHotkey.
Re: Class_ScrollGUI - updated on 2015-02-13
I recently noticed this issue, too. It might be a bug in AHK (script_gui.cpp). I'll ask in Ask For Help before I try to fix something.
Re: Class_ScrollGUI - updated on 2015-02-13
@bichlepa: The issue should be fixed with AHK 1.1.20.00.
Re: Class_ScrollGUI - updated on 2015-02-13
Thanks! It's fixed.
Scripting is too complicated? Try AutoHotFlow, the graphical automation tool! Written in AutoHotkey.
Re: Class_ScrollGUI - updated on 2015-02-13
After some more testing I seemingly learned a bit more about the wheel message handling. It seems that the messages are sent to the focused control but returned to the parent window chain, if the control doesn't process the message (e.g. if it is not scrollable). Additionally, it seems that all common controls don't process wheel messages whenever a modifier key (Ctrl or Shift) is down. That's why I made a new version of ScrollGUI:
Changes:
- Wheel messages are processed by the ScrollGUI whenever the mouse is hovering over one of its scoll bars.
- Wheel messages are passed to the child GUI's controls, so scrolling within controls is possible.
- Message handling has been updated to use the new capabilities of AHK 1.1.20+.
- Scroll bar adjustments after resizing the ScrollGUI are now done internally. Previously necessary calls of AdjustToParent() are obsolete.
Code: Select all
Removed!
Code: Select all
Moved to the OP
Last edited by just me on 13 Mar 2015, 09:15, edited 1 time in total.
Re: Class_ScrollGUI - updated on 2015-02-13
It works on windows 7 and Windows XP. I've tested the vertical scrollbar and the vertical mouse wheel in my AutoHotFlow script. When an GUI Element is selected that uses the mouse wheel it doesn's scroll but scrolls within the element.
Great work!
Great work!
Scripting is too complicated? Try AutoHotFlow, the graphical automation tool! Written in AutoHotkey.
Re: Class_ScrollGUI - updated on 2015-03-13
Thanks for testing, bichlepa. Hoping that all will work as intended I've updated the OP.
Re: Class_ScrollGUI - updated on 2015-03-13
Hello, this is great script just me.
I have a simple question. Just trying to get the background to be black for your sample script with no luck. I used the standard command, Gui, Color, Black with no success. Thanks for the help.
I have a simple question. Just trying to get the background to be black for your sample script with no luck. I used the standard command, Gui, Color, Black with no success. Thanks for the help.
Re: Class_ScrollGUI - updated on 2015-03-13
Gui, Color, Black is working for me.
Re: Class_ScrollGUI - updated on 2015-03-13
Thanks for the quick reply. I figured it out. I didn't put a return where I should have. In addition I have something I would like to get working, but unsure how. I put a scrolling window text in the sample script, yet doesn't scroll.just me wrote:Gui, Color, Black is working for me.
Code: Select all
#NoEnv
#Include Class_ScrollGUI.ahk
SetBatchLines, -1
; ----------------------------------------------------------------------------------------------------------------------
; ChildGUI 1
Text :=" this text will scroll one character at a time from right to left all day"
Gui, New, +hwndHGUI ;+Resize
Gui, Margin, 20, 20
Gui, Color, Black
Gui, Font, s14 CWhite, Tahoma
I := 0
Gui, Add, Button, vBtn1, Test Button
Gui, add, text, cWhite vMytext gLaunchGoogle, % Text
Gui, Font, s14 CBlue, Tahoma
Gui, Add, Text, w370 h20 0x200 Section, % "Edit " . ++I
Gui, Add, Edit, xp y+0 wp r6 vEdit10, 1`n2`n3`n4`n5`n6`n7`n8`n9
Loop, 4
{
Gui, Add, Text, xp y+0 wp h20 0x200, % "Edit " . ++I
Gui, Add, Edit, xp y+0 wp r6 vEdit1%A_Index%, 1`n2`n3`n4`n5`n6`n7`n8`n9
}
Gui, Add, Text, ys wp h20 0x200, % "Edit " . ++I
Gui, Add, Edit, xp y+0 wp r6 vEdit20, 1`n2`n3`n4`n5`n6`n7`n8`n9
Loop, 4
{
Gui, Add, Text, xp y+0 wp h20 0x200, % "Edit " . ++I
Gui, Add, Edit, xp y+0 wp r6 vEdit2%A_Index%, 1`n2`n3`n4`n5`n6`n7`n8`n9
}
; Create ScrollGUI1 with both horizontal and vertical scrollbars and scrolling by mouse wheel
Global SG1 := New ScrollGUI(HGUI, 500, 400, "+Resize +LabelGui1 +AlwaysOnTop", 3, 4)
; Show ScrollGUI1
SG1.Show("ScrollGUI1", "xCenter yCenter")
SetTimer, scroll, 200
return
scroll:
if !ScrollText
ScrollText := Text
StringTrimLeft, ScrollText, ScrollText, 1
GuiControl,,MyText, % ScrollText
return
LaunchGoogle:
Run www.google.com
return
Side note. Is there an altercation to the scrolling script that can make it scroll bottom to top constantly? Thanks for the help.
Re: Class_ScrollGUI - updated on 2015-03-13
Hi newpie,
these questions rather belong to "Ask For Help".
The default GUI number/name for non-GUI threads like timers is 1. The parent GUI of the control you want to scroll has no number/name. So you have to specify the GUI in GuiControl either by using its HWND (%HGUI%:) or a name/number specified inGui, NameOrNumber:New.
these questions rather belong to "Ask For Help".
The default GUI number/name for non-GUI threads like timers is 1. The parent GUI of the control you want to scroll has no number/name. So you have to specify the GUI in GuiControl either by using its HWND (%HGUI%:) or a name/number specified inGui, NameOrNumber:New.
Re: Class_ScrollGUI - updated on 2015-03-13
Thanks just me, I will try to make sure to ask in the correct area next time.
Re: Class_ScrollGUI - updated on 2015-03-13
The Class_ScrollGUI is doing a good job in AutoHotFlow.
Sometimes the Settings GUI is very high, therefor I use the scrollable GUI. Now, if the GUI is very high, the OK and Cancel buttons are on the bottom of the GUI. So, to reach them the GUI must be scrolled down. Is it possible to add those two buttons to the parent GUI, in order to make them always visible? It should look like in this edited image:
Sometimes the Settings GUI is very high, therefor I use the scrollable GUI. Now, if the GUI is very high, the OK and Cancel buttons are on the bottom of the GUI. So, to reach them the GUI must be scrolled down. Is it possible to add those two buttons to the parent GUI, in order to make them always visible? It should look like in this edited image:
Scripting is too complicated? Try AutoHotFlow, the graphical automation tool! Written in AutoHotkey.
Re: Class_ScrollGUI - updated on 2015-03-13
Glad to see that someone is actively developing a scrolling system.
I have dabbled with my own systems, but I have a lot of other projects at the moment which I am actively working on, so I am starting to lean towards using this lib instead for my scrollbar needs.
How well does this code play with Gui Resizing libraries such as Attach, Anchor, AutoXYWH etc?
I would really like to see something like example 1, but when you size the window up so that all the edit boxes are visible, if you size X up any more, the edit boxes grow in width appropriately (eg Edit1 and Edit6 share the width evenly)
I have dabbled with my own systems, but I have a lot of other projects at the moment which I am actively working on, so I am starting to lean towards using this lib instead for my scrollbar needs.
How well does this code play with Gui Resizing libraries such as Attach, Anchor, AutoXYWH etc?
I would really like to see something like example 1, but when you size the window up so that all the edit boxes are visible, if you size X up any more, the edit boxes grow in width appropriately (eg Edit1 and Edit6 share the width evenly)
Re: Class_ScrollGUI - updated on 2015-03-13
@bichlepa:
Though the class is not designed to be used in this manner, something like the following might work:
Though the class is not designed to be used in this manner, something like the following might work:
Code: Select all
#NoEnv
#Include Class_ScrollGUI.ahk
SetBatchLines, -1
; ----------------------------------------------------------------------------------------------------------------------
; ChildGUI
Gui, New, +hwndHGUI
Gui, Margin, 20, 20
I := 0
Gui, Add, Text, w370 h20 0x200, % "Edit " . ++I
Gui, Add, Edit, xp y+0 wp r6 vEdit10, 1`n2`n3`n4`n5`n6`n7`n8`n9
Loop, 4 {
Gui, Add, Text, xp y+0 wp h20 0x200, % "Edit " . ++I
Gui, Add, Edit, xp y+0 wp r6 vEdit1%A_Index%, 1`n2`n3`n4`n5`n6`n7`n8`n9
}
; Create ScrollGUI1 with vertical scrollbar and scrolling by mouse wheel
Global SG1 := New ScrollGUI(HGUI, 0, 400, "", 2, 4)
; Create the main window (parent)
Gui, Main:New
Gui, Margin, 0, 20
Gui, % SG1.HWND . ": -Caption +ParentMAIN +LastFound"
Gui, % SG1.HWND . ":Show", Hide
WinGetPos, , , W, H
W := Round(W * (96 / A_ScreenDPI))
H := Round(H * (96 / A_ScreenDPI))
Y := H + 20
Gui, Add, Button, x20 y%Y% w100, Save
Gui, Add, Button, x+20 yp wp, Cancel
Gui, Show, w%W%, Settings
; Show ScrollGUI1
SG1.Show("", "x0 y0")
Return
; ----------------------------------------------------------------------------------------------------------------------
MainGuiClose:
MainGuiEscape:
ExitApp
Re: Class_ScrollGUI - updated on 2015-03-13
Thank you!
It works so far. I didn't mention one thing: The GUI height must be resizeable. (The width must stay as is.)
I managed to move the buttons, but I didn't manage to resize the Scrollable GUI. These are my attempts by now:
It works so far. I didn't mention one thing: The GUI height must be resizeable. (The width must stay as is.)
I managed to move the buttons, but I didn't manage to resize the Scrollable GUI. These are my attempts by now:
Code: Select all
#NoEnv
#Include Class_ScrollGUI.ahk
SetBatchLines, -1
; ----------------------------------------------------------------------------------------------------------------------
; ChildGUI
Gui, New, +hwndHGUI
Gui, Margin, 20, 20
I := 0
Gui, Add, Text, w370 h20 0x200, % "Edit " . ++I
Gui, Add, Edit, xp y+0 wp r6 vEdit10, 1`n2`n3`n4`n5`n6`n7`n8`n9
Loop, 4 {
Gui, Add, Text, xp y+0 wp h20 0x200, % "Edit " . ++I
Gui, Add, Edit, xp y+0 wp r6 vEdit1%A_Index%, 1`n2`n3`n4`n5`n6`n7`n8`n9
}
; Create ScrollGUI1 with vertical scrollbar and scrolling by mouse wheel
Global SG1 := New ScrollGUI(HGUI, 0, 400, "", 2, 4)
; Create the main window (parent)
Gui, Main:New
Gui, Margin, 0, 20
Gui, % SG1.HWND . ": -Caption +ParentMAIN +LastFound"
Gui, % SG1.HWND . ":Show", Hide
WinGetPos, , , W, H,% "ahk_id " SG1.HWND
W := Round(W * (96 / A_ScreenDPI))
H := Round(H * (96 / A_ScreenDPI))
Y := H + 20
;Make resizeable
gui,+resize
gui,+minsize%w%x100 ;Ensure contant width.
gui,+maxsize%w%x%A_ScreenHeight%
Gui, Main:Add, Button, vButtonSave x20 y%Y% w100, Save
Gui, Main:Add, Button, vButtonCancel x+20 yp wp, Cancel
Gui, Main:Show, w%W%, Settings
Gui, Main:Show, w%W%, Settings ;Needed twice, otherwise the width is not correct
; Show ScrollGUI1
SG1.Show("", "x0 y0")
Return
; ----------------------------------------------------------------------------------------------------------------------
MainGuiClose:
MainGuiEscape:
ExitApp
MainGuisize(GuiHwnd, EventInfo, Width, Height)
{
guicontrol, main:move,ButtonSave,% "y" Height-40
guicontrol, main:move,ButtonCancel,% "y" Height-40
;attempt 1 ;Everything disappears
winmove,% "ahk_id " SG1.HWND, , , , ,% Height-60
;attempt 2 ;Everything disappears
;~ SG1.height:=Height-60
;~ sg1.show()
;attempt 3 ;Nothing happens
;SG1.size(,Height-60)
ToolTip % Width " " Height " " GUIHWND "`n" SG1.HWND
}
ExitApp
Scripting is too complicated? Try AutoHotFlow, the graphical automation tool! Written in AutoHotkey.
Re: Class_ScrollGUI - updated on 2015-03-13
If you try to resize a child window using WinMove or Gui, Show you have to specify the the position (X, Y) relative to the parent window. Otherwise, the current position is used, which means that screen coordinates (the current position) are used as client coordinates and the child will be will moved out of the client area of the parent in this case.
I don't think that it is a good idea to change the properties of the ScrollGui object directly. But you should respect MaxH (maximum width) and MaxV (maximum height) when resizing a ScrollGui this way.
BTW: Why do you need a scrollable child window as well as a rezizable parent window?
I don't think that it is a good idea to change the properties of the ScrollGui object directly. But you should respect MaxH (maximum width) and MaxV (maximum height) when resizing a ScrollGui this way.
BTW: Why do you need a scrollable child window as well as a rezizable parent window?
Re: Class_ScrollGUI - updated on 2015-03-13
Thank you, it works now! The x and y coordinates did it.
It's not very useful, but it is cool.
That's how it looks now:
Well, a good question.just me wrote:BTW: Why do you need a scrollable child window as well as a rezizable parent window?
It's not very useful, but it is cool.
That's how it looks now:
Scripting is too complicated? Try AutoHotFlow, the graphical automation tool! Written in AutoHotkey.
Re: Class_ScrollGUI - updated on 2015-03-13
I am trying to integrate Attach and Class_ScrollGUI to make a scrollable child GUI inside a Tab Control that resizes with the main Gui - similar I guess to what bichlepa is trying to do.
I have all the other bits working, but I cannot get the ScrollGui window to resize - it seems to be because you are parenting Guis in ScrollGui?
Here is how it should behave (Minus the scrollbars):
I just can't get your class to make the ScrollGui resize when the parent resizes. The commented out lines are my attempt at integrating SG.
Any ideas?
The goal is to allow people to take a script (ie hard-coded hotkeys, settings etc) and easily turn it into a user-friendly "Application" that is configurable by end-users with no knowledge of AHK.
Script writers can include my library, and it wraps their script with useful functionality:
The Script author has his own "Client" Gui (The one inside the Tab Control), so all Gui, Add commands that the script author uses can use coordinates relative to the "Client" Gui.
Therefore, as I do not know how many GuiControls will be inside the Client Gui, I need scrollbars inside the Tab control to accommodate for any size of Client Gui.
Here is a GIF of the profile / persistent settings system in action (I havent done the child Gui part for it yet, just the Hotkey GuiControl and the Profile system:
The Hotkey GuiControl is here: https://github.com/evilC/HotClass
I have all the other bits working, but I cannot get the ScrollGui window to resize - it seems to be because you are parenting Guis in ScrollGui?
Here is how it should behave (Minus the scrollbars):
Code: Select all
#SingleInstance force
#Include <attach>
#Include <Class_ScrollGUI>
mc := new MyClass()
class MyClass {
__New(){
Gui +resize
Gui, Add, Tab2, hwndhTab w200 h200, Tab A|Tab B
fn := this.OnSize.Bind(this)
Gui +HwndhDef
Gui, Add, Text, hwndhEdit w180 h160
Gui, New, hwndhChild -Border
this.hChild := hChild
Gui, Color, FF0000
Loop 10 {
Gui, Add, Edit, xm w300
}
Gui, Show, x0 y0 w180 h160
;this.SG1 := New ScrollGUI(hChild, 180, 160, "+Resize +LabelGui1 -Border", 3, 4)
;this.SG1.Show("ScrollGUI1", "x0 y0 w180 h160")
Gui, % "+Parent" hEdit
Attach(hTab,"w1 h1")
Attach(hEdit,"w1 h1")
Gui, % hDef ":Show"
OnMessage(0x0005, fn)
}
OnSize(wParam, lParam){
dllcall("MoveWindow", "Ptr", this.hChild, "int", 0,"int", 0, "int", lParam & 0xffff, "int", lParam >> 16, "int", 0)
;dllcall("MoveWindow", "Ptr", this.SG1.HWND, "int", 0,"int", 0, "int", lParam & 0xffff, "int", lParam >> 16, "int", 0)
}
}
Any ideas?
In my case, I am writing a Rapid Application Development framework for AHK called RADical.BTW: Why do you need a scrollable child window as well as a rezizable parent window?
The goal is to allow people to take a script (ie hard-coded hotkeys, settings etc) and easily turn it into a user-friendly "Application" that is configurable by end-users with no knowledge of AHK.
Script writers can include my library, and it wraps their script with useful functionality:
- Decent Hotkey GuiControls that allow the end-user to choose which Hotkey activates the script functions (Supports Keyboard, Mouse, Joystick buttons,Joystick Hat directions or any combination thereof - eg Ctrl+Lbutton+Joystick 2 Hat Up)
- Persistent settings (Contents of GuiControls and Hotkey bindings saved between runs).
- Profile support (End user can create profiles which allow for sets of settings to be swapped in and out).
- etc, etc.
The Script author has his own "Client" Gui (The one inside the Tab Control), so all Gui, Add commands that the script author uses can use coordinates relative to the "Client" Gui.
Therefore, as I do not know how many GuiControls will be inside the Client Gui, I need scrollbars inside the Tab control to accommodate for any size of Client Gui.
Here is a GIF of the profile / persistent settings system in action (I havent done the child Gui part for it yet, just the Hotkey GuiControl and the Profile system:
The Hotkey GuiControl is here: https://github.com/evilC/HotClass
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: Raidiologist and 103 guests