Page 1 of 1

How to smoothly scroll an Editor Gadget?

Posted: Fri Jan 20, 2017 1:09 am
by IdeasVacuum
This code scrolls the text in an EditorGadget:

Code: Select all

iPause.i = 900
 iLine.i = 0
iTotal.i = CountGadgetItems(#EditorGdgt)

While (iLine < iTotal)
                Delay(iPause)
         SendMessage_(GadgetID(#EditorGdgt),#EM_LINESCROLL,0,1)
         iLine = iLine + 1
Wend
.... efficient, but not smooth. I suspect it is possible to get smoother scrolling by moving the scroll bar programmatically?

Re: How to smoothly scroll an Editor Gadget?

Posted: Fri Jan 20, 2017 4:06 pm
by pstryk
With WinApi:

Code: Select all

OpenWindow(0,60,60,500,500,"Scroll")
EditorGadget(0,0,0,500,500)
 position.POINT
For x=0 To 500
  AddGadgetItem(0, x, "Line: "+Str(x))
Next x
GetScrollRange_(GadgetID(0), #SB_VERT, @minpos, @maxpos)
While event<>#PB_Event_CloseWindow And maxpos>position\y
  If time+10<ElapsedMilliseconds()
  SendMessage_(GadgetID(0), #EM_GETSCROLLPOS, 0, position.POINT)
  position\y+1
  SendMessage_(GadgetID(0), #EM_SETSCROLLPOS, 0, position)
  time=ElapsedMilliseconds()
  EndIf
  event=WindowEvent()
Wend  

Re: How to smoothly scroll an Editor Gadget?

Posted: Fri Jan 20, 2017 7:20 pm
by IdeasVacuum
Thanks for the code snippet pstryk - but the performance is similar to my code if run more slowly.

Re: How to smoothly scroll an Editor Gadget?

Posted: Sat Jan 21, 2017 2:54 am
by IdeasVacuum
...in fact pstryk, your snippet runs similarly to my code but if I incorporate the method into my app code, it does actually scroll nicely, much smoother! Strange thing is, it only works when the font size is less than 26. My app will often be using much larger font sizes (80 to 120), variable on-the-fly.