TScrollBar
Fonte: source/classes/scrllbar.prg
Inherits from: TControl
TScrollBar is a standalone scrollbar control that can be placed independently within a window or dialog. Unlike window automatic scroll bars, TScrollBar is a control object that fires action blocks when the user scrolls, making it suitable for custom browse panels, range selectors, and scrollable containers.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
nMin | Numeric | Minimum scrollbar value |
nMax | Numeric | Maximum scrollbar value |
nPgStep | Numeric | Page-step increment for the scrollbar |
lVertical | Logical | .T. for vertical scrollbar, .F. for horizontal |
bGoUp | Block | Action on small increment (down arrow / right arrow) |
bGoDown | Block | Action on small decrement |
bGoTop | Block | Action on reaching the top/left extreme |
bGoBottom | Block | Action on reaching the bottom/right extreme |
bPageUp | Block | Action on page increment (click above the thumb) |
bPageDown | Block | Action on page decrement |
Methods
| Method | Description |
|---|---|
New( nRow, nCol, nMin, nMax, nPgStep, lVert, oWnd ) | Create a new scrollbar control |
WinNew( nMin, nMax, nPgStep, lVert, oWnd ) | Create a scrollbar using window coordinates |
GoUp() | Scroll up/right by one step |
GoDown() | Scroll down/left by one step |
GoTop() | Scroll to the minimum position |
GoBottom() | Scroll to the maximum position |
PageUp() | Scroll up by one page step |
PageDown() | Scroll down by one page step |
SetPos( n ) | Set the thumb position to n |
GetPos() | Return the current thumb position |
Example: Vertical Scrollbar Linked to Browse
#include "FiveWin.ch"
function Main()
local oWnd, oScroll, nPos := 1
DEFINE WINDOW oWnd TITLE "ScrollBar Demo" SIZE 300, 300
@ 10, 260 SCROLLBAR oScroll ;
RANGE 1, 100 ;
PAGE 10 ;
VERTICAL OF oWnd ;
ON UP nPos-- ;
ON DOWN nPos++
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- Use
VERTICALclause for a vertical scrollbar; omit it or useHORIZONTALfor a horizontal scrollbar. - The
RANGEclause setsnMinandnMax. ThePAGEclause setsnPgStep. - Action blocks (
ON UP,ON DOWN,ON PAGEUP,ON PAGEDN) fire when the user interacts with the corresponding scrollbar regions. - TScrollBar is ideal for custom scrolling in browse-like controls where the window's built-in scroll bars are not used.