TScrollMetro
Source: source/classes/scrollm.prg
Inherits from: TControl
TScrollMetro provides a modern Metro-style scrollbar control. It replaces the classic Windows scrollbar with a flat, touch-friendly design suitable for tablet and modern UI applications. The control supports programmatic positioning, range management, and code-block event hooks for all scroll actions.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
lVertical | Logical | Orientation: .T. for vertical, .F. for horizontal |
nMin / nMax | Numeric | Scroll range minimum and maximum values |
nPgStep | Numeric | Page step increment for page-up/page-down actions |
nPos | Numeric | Current scroll thumb position |
bGoUp / bGoDown | Code block | Executed when the up/left or down/right button is clicked |
bGoTop / bGoBottom | Code block | Executed when the thumb is dragged to the top or bottom |
bPageUp / bPageDown | Code block | Executed on page-up/page-down track area click |
bPos / bTrack | Code block | Executed on position change and thumb tracking |
Methods
| Method | Description |
|---|---|
New( nRow, nCol, nMin, nMax, nPgStep, lVert, oWnd, nW, nH ) | Create a new Metro scrollbar with range, step, and orientation |
SetRange() | Update the scroll range from nMin and nMax values |
SetPos( nPos ) / GetPos() | Set or retrieve the current scroll thumb position |
GoUp() / GoDown() | Move the thumb up (or left) / down (or right) by one step |
GoTop() / GoBottom() | Move the thumb to the minimum or maximum position |
PageUp() / PageDown() | Move the thumb by the page step amount |
Example: Vertical Scrollbar for Browse
#include "FiveWin.ch"
function Main()
local oWnd, oScroll
local nPos := 0
DEFINE WINDOW oWnd TITLE "TScrollMetro Demo" SIZE 400, 300
oScroll := TScrollMetro():New( 10, 370, 0, 100, 10, .T., oWnd, 20, 250 )
oScroll:bGoUp := { || nPos := oScroll:GetPos(), oWnd:Refresh() }
oScroll:bGoDown := { || nPos := oScroll:GetPos(), oWnd:Refresh() }
oScroll:bPageUp := { || nPos := oScroll:GetPos(), oWnd:Refresh() }
oScroll:bPageDown:= { || nPos := oScroll:GetPos(), oWnd:Refresh() }
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- The control fires code-block events for each scroll action:
bGoUp,bGoDown,bGoTop,bGoBottom,bPageUp,bPageDown,bPos, andbTrack. - Orientation is set at creation time via the
lVertparameter and cannot be changed dynamically. - Use
SetRange()after changingnMinornMaxto recalibrate the scroll thumb. - The Metro scrollbar is particularly suited for touch-screen applications where the narrow track of classic scrollbars is difficult to interact with.