Class_ScrollGUI - updated on 2015-03-13

Post your working scripts, libraries and tools
DRocks
Posts: 556
Joined: 08 May 2018, 10:20

Re: Class_ScrollGUI - updated on 2015-03-13

15 Jan 2020, 21:31

kczx3 wrote:
15 Jan 2020, 20:24
It’s probably just the sheer number of controls based on the fact that you’re mimicking an excel spreadsheet
Yeah I agree with you but let's hope someone smarter than me can think of a way to handle this. In my example, there's not an enourmous amount of controls and still it feels like there is 100 000 controls.
To be exact, there are about 1090 controls (99 rows * 11 cols).
Even my 5ghz processor is having issues so I guess there's some reason (- which is above my knowledge of how the dllcalls and stuff work in the class).
just me
Posts: 6805
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class_ScrollGUI - updated on 2015-03-13

16 Jan 2020, 11:55

Ok, I can reproduce the issue with a child GUI containing 99 * 12 edit controls without own message handlers or contgrol labels (Win 10 Pro 64 1903, AHK 1.1.32.00 U64). And I don't know, why it happens. I'd guess it has something to do with an overflooded message queue but I'm not able to degug such scenarios.

My test script:

Code: Select all

#NoEnv
#KeyHistory, 0
SetBatchLines, -1
ListLines, Off
Gui, Dummy:New
Gui, Child:New, +hwndHCHILD +ParentDummy
Gui, Margin, 10, 10
Loop, 99 {
   X := "xm"
   Y := A_Index = 1 ? "" : "y+-1"
   Loop, 12 {
      Gui, Add, Edit, %X% %Y% w100, Edit!
      X := "x+-1"
      Y := "yp"
   }
}
ScrollableResultats:= New ScrollGUI(HCHILD, 800, 600, "+Resize", 3, 4)
MainGuiTitle := "Finance D - "
ScrollableResultats.Show(MainGuiTitle)
Return
Esc::ExitApp

#Include Class_ScrollGUI.ahk
DRocks
Posts: 556
Joined: 08 May 2018, 10:20

Re: Class_ScrollGUI - updated on 2015-03-13

16 Jan 2020, 18:04

I like how clean you can create a 1188 controls GUI :D

Good to know that it's not only reproduced on my computer in my specific script.
I gotta admit that I have no idea how to fix this either.
I've gone through the class but since its majorly dllCalls and numput numget etc I can't understand where I could help.
Only clue I might have is this:

Code: Select all

		For Key, Value In Values {
			If SIF.HasKey(Key) {
				Mask |= SIF[Key]
				NumPut(Value, SI, Off[Key], "UInt")
			}
		}
or this

Code: Select all

		While (HWND := DllCall("GetWindow", "Ptr", HWND, "UInt", CMD, "UPtr")) && (CMD := 2) {
			WinGetPos, X, Y, W, H, ahk_id %HWND%
			W += X, H += Y
			WinGet, Styles, Style, ahk_id %HWND%
			If (Styles & 0x10000000) { ; WS_VISIBLE
				If (L = "") || (X < L)
					L := X
				If (T = "") || (Y < T)
					T := Y
				If (R = "") || (W > R)
					R := W
				If (B = "") || (H > B)
					B := H
			}
			Else {
				If (LH = "") || (X < LH)
					LH := X
				If (TH = "") || (Y < TH)
					TH := Y
			}
		}
Would there be a way to put a sleep, 10 ms somewhere to slow it down maybe?
Or skip some fast happening chunks of data incoming?
DRocks
Posts: 556
Joined: 08 May 2018, 10:20

Re: Class_ScrollGUI - updated on 2015-03-13

16 Jan 2020, 20:25

EDIT: never mind, I found something useable by Setting the line increment of scroll to the height of a table row.

Code: Select all

scrollable_UI.SetLine(2, TABLE_ROW_H-1)
Hey side-question:

How would you programmatically use ScrollGUI to follow the focused control when you want to navigate with arrow keys inside the scroll gui ?
Like how do you know when you're out of view and need to scroll up or down ?
I am trying with Send WheelUp Down but doesn't do what is expected because I don't when when the control is out of view.
Any idea?

Code: Select all

 ;#[HotKeys MainUI]
#if WinActive(MainGuiTitle)

Up::
Down::
focus_next_row()
return

;...
just me
Posts: 6805
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class_ScrollGUI - updated on 2015-03-13

17 Jan 2020, 06:24

DRocks wrote:Only clue I might have is this:
This must be called for every scroll positionn change. It shouldn't take much time.

DRocks wrote:or this
This is usually called only once when the SrollGUI will be created.

DRocks wrote: EDIT: never mind, I found something useable by Setting the line increment of scroll to the height of a table row.
SetLine(2, TABLE_ROW_H-1)
That's strange, because 2 isn't valid. Replacing it with 1 (vertical scroll bar) and using my Edit control's height doesn't work for me.

DRocks wrote:Like how do you know when you're out of view and need to scroll up or down ?
You could compare the sreen coordinates of the control with the screen coordinates of the client area of the ScrollGUI window.
DRocks
Posts: 556
Joined: 08 May 2018, 10:20

Re: Class_ScrollGUI - updated on 2015-03-13

17 Jan 2020, 08:37

Thanks!
just me wrote:
17 Jan 2020, 06:24
DRocks wrote: EDIT: never mind, I found something useable by Setting the line increment of scroll to the height of a table row.
SetLine(2, TABLE_ROW_H-1)
That's strange, because 2 isn't valid. Replacing it with 1 (vertical scroll bar) and using my Edit control's height doesn't work for me.

Code: Select all

   ; ===================================================================================================================
   ; SetLine        Sets the number of pixels to scroll by line.
   ; Parameters:
   ;    SB          -  Scroll bar to set the value for:
   ;                   1 = horizontal
   ;                   2 = vertical
   ;    Line        -  Number of pixels.
   ; Return values:
   ;    On success: True
   ;    On failure: False
   ; ===================================================================================================================
	SetLine(SB, Line) {
      ; SB_HORZ = 0, SB_VERT = 1
		SB--
		If (SB <> 0) && (SB <> 1)
			Return False
		If (SB = 0)
			This.LineH := Line
		Else
			This.LineV := Line
		Return True
	}
Maybe there's a typo cause at first I tried 1 and it didn't work then I re-read the comments in the class and saw vertical should be 2

Code: Select all

   ; Parameters:
   ;    SB          -  Scroll bar to set the value for:
   ;                   1 = horizontal
   ;                   2 = vertical
User avatar
kczx3
Posts: 1039
Joined: 06 Oct 2015, 21:39

Re: Class_ScrollGUI - updated on 2015-03-13

17 Jan 2020, 14:10

I have a gui that uses AHK v2 and functions based on Lexikos' code. It struggles as well with your requirements.

EDIT: Here's a short clip of that gui that has quite a few controls and it is smooth for me.
scroll-gui.gif
scroll-gui.gif (805.86 KiB) Viewed 489 times
DRocks
Posts: 556
Joined: 08 May 2018, 10:20

Re: Class_ScrollGUI - updated on 2015-03-13

17 Jan 2020, 16:47

Yeah I think just me is also based on lexikos model for the crucial parts. Not sure though.
just me
Posts: 6805
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class_ScrollGUI - updated on 2015-03-13

18 Jan 2020, 08:31

DRocks wrote:
17 Jan 2020, 08:37
...
Sorry, my bad. I overlooked the

Code: Select all

      SB--

Return to “Scripts and Functions”

Who is online

Users browsing this forum: jj4156, nacken012 and 91 guests