TScrollPanelEx

Fuente: source/classes/scrollex.prg

Inherits from: TPanel

TScrollPanelEx is an enhanced scrollable panel that supports horizontal scrolling of child controls with keyboard, mouse wheel, scroll bar, and gesture (touch/pan) input. It tracks the leftmost and rightmost child controls to compute the scroll range and provides automatic scrollbar management. The panel is commonly used for toolbars, ribbon-style layouts, and overflow containers.

Key DATA Members

DATATypeDescription
hStepNumericHorizontal scroll step in pixels (default 20)
nScrollRangeNumericComputed scroll range based on child control positions
oCtrlLeftObjectLeftmost child control (used for scroll boundary)
oCtrlRightObjectRightmost child control
nRightMarginNumericRight margin for auto-resize
nBottomMarginNumericBottom margin for auto-resize
aPagesArrayNamed page positions for GoToPage navigation
lScrollDragLogicalDrag-to-scroll mode flag

Methods

MethodDescription
New( nTop, nLeft, nBottom, nRight, oWnd, lNoBorder )Create a scrollable panel. Pass lNoBorder := .T. to omit the border
Redefine( nId, oWnd, lNoBorder )Redefine from a dialog resource
SetRange()Scan child controls and set the scroll range
ScrollBy( nPix )Scroll content horizontally by the given pixel offset
GoLeft() / GoRight()Scroll to the extreme left or right
GoLeftPix( nPix ) / GoRightPix( nPix )Scroll by a specific pixel amount
PageLeft() / PageRight()Scroll by two step sizes (page-style)
GoToPos( nPos )Scroll to an absolute scrollbar position
GoToPage( cPage )Scroll to a named page (registered via SetPage)
SetPage( cPage, nCol )Register a named page at a given column position
ControlIntoView( oControl )Scroll to ensure a specific control is visible
hScroll( nWParam, nLParam )Handle horizontal scroll bar messages
MouseWheel( nKeys, nDelta, nXPos, nYPos )Handle mouse wheel for horizontal scrolling
HandleGesture( nGesture, nLParam )Handle touch pan gestures (kinetic scrolling)

Example: Smooth Scroll Panel with Child Controls

#include "FiveWin.ch"

function Main()

   local oWnd, oPanel, oBtn

   DEFINE WINDOW oWnd TITLE "TScrollPanelEx Demo" SIZE 600, 150

   @ 20, 20 SCROLLPANEX oPanel SIZE 560, 60 OF oWnd

   for n := 1 to 15
      @ 10, ( n - 1 ) * 90 BUTTON "Btn " + Str( n ) ;
         SIZE 80, 30 OF oPanel PIXEL
   next

   oPanel:SetRange()

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

Ver También