THorzScroll

Source: source/classes/hrzscrol.prg

Inherits from: TPanel

THorzScroll extends TPanel with a built-in horizontal scrollbar that scrolls a collection of child panels. It is designed for horizontally scrollable layouts such as dashboard card rows, toolbar panels, or image galleries where content exceeds the visible width.

Key DATA Members

DATATypeDescription
oHScrollObjectTScrollBar object managing the horizontal scrollbar
nHPosNumericCurrent horizontal scroll position
nMaxWidthNumericTotal content width; determines the scroll range
aPanelsArrayArray of child TPanel objects managed by the container
nBetweenNumericSpacing in pixels between consecutive panels (default 10)
lBorderLogicalShow a border around the container
nClrBorderNumericBorder color (RGB value)

Methods

MethodDescription
New( nTop, nLeft, nBottom, nRight, oWnd, nClrPane, lHScroll, lBorder, nClrBorder )Create a new horizontal scroll panel
Redefine( nId, oWnd, nClrPane, lHScroll, lBorder, nClrBorder )Redefine from a dialog resource
AddPanel( nWidth, nClrBack )Add a child panel to the scrollable area; returns the panel object
RemovePanel( xParam )Remove a child panel by index or object reference
HScroll( nCode )Handle scroll events (line left/right)
UpdateScrollRange()Recalculate the scrollbar range after adding/removing panels
StartSmoothScroll( nNewPos )Begin smooth animated scrolling to a target position

Example: Horizontal Scroll Panel

#include "FiveWin.ch"

function Main()

   local oWnd, oHS, oP1, oP2, oP3

   DEFINE WINDOW oWnd TITLE "THorzScroll Demo" SIZE 600, 200

   @ 10, 10 PANEL oHS OF oWnd SIZE 560, 150

   oP1 := oHS:AddPanel( 150, CLR_RED )
   oP2 := oHS:AddPanel( 150, CLR_GREEN )
   oP3 := oHS:AddPanel( 150, CLR_BLUE )

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also