TPager
Source: source/classes/tpager.prg
Inherits from: TControl
TPager is a wrapper for the Win32 SysPager common control. It provides scroll buttons (arrows) that allow the user to navigate through a child window that is larger than the visible area. Typically used with toolbar controls or other wide child windows that need horizontal or vertical scrolling without standard scrollbars.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
oChild | Object | The child window/control contained within the pager |
lHorz | Logical | Horizontal orientation (default .F. = vertical) |
lAutoScroll | Logical | Enable auto-scrolling when mouse hovers near edge |
lDragDrop | Logical | Enable drag-and-drop scrolling |
nBtnSize | Numeric | Size of the scroll arrow buttons (default 12) |
nBkColor | Numeric | Background color (default COLOR_BTNFACE) |
nBorder | Numeric | Border width in pixels (default 0) |
Methods
| Method | Description |
|---|---|
New( nTop, nLeft, oWnd, oChild, nW, nH, lPixel, lDesign, cMsg, bWhen, bChange, bGotFocus, bLostFocus, lHorz, lAutoScroll, lDragDrop, nBtnSize, nBkColor, nBorder ) | Create a new TPager control |
ReDefine( nId, oWnd, cMsg, bWhen, bChange, bGotFocus, bLostFocus, nBtnSize, nBkColor, nBorder ) | Redefine from dialog resource |
SetChild( oChild ) | Set or change the child window contained in the pager |
RecalcSize() | Recalculate pager size and scroll button visibility |
SetPos( nPos ) | Set the current scroll position (offset) |
GetPos() | Retrieve the current scroll position |
SetButtonSize( nSize ) | Set the size of the scroll arrow buttons |
GetButtonSize() | Retrieve the current button size |
GetButtonState( nButton ) | Get the state of a scroll button (PGB_TOPORLEFT or PGB_BOTTOMORRIGHT) |
SetBkColor( nColor ) | Set the background color |
GetBkColor() | Retrieve the background color |
SetBorder( nBorder ) | Set the border width |
GetBorder() | Retrieve the border width |
ForwardMouse( lForward ) | Forward mouse events to the child window |
Example: Horizontal Pager with Toolbar
#include "FiveWin.ch"
function Main()
local oWnd, oPager, oToolBar
DEFINE WINDOW oWnd TITLE "Pager Demo" SIZE 600, 100
// Create a toolbar with many buttons
DEFINE BUTTONBAR oToolBar OF oWnd SIZE 800, 30
DEFINE BUTTON OF oToolBar PROMPT "File"
DEFINE BUTTON OF oToolBar PROMPT "Edit"
DEFINE BUTTON OF oToolBar PROMPT "View"
DEFINE BUTTON OF oToolBar PROMPT "Tools"
DEFINE BUTTON OF oToolBar PROMPT "Format"
DEFINE BUTTON OF oToolBar PROMPT "Insert"
DEFINE BUTTON OF oToolBar PROMPT "Table"
DEFINE BUTTON OF oToolBar PROMPT "Help"
// Wrap toolbar in a horizontal pager
TPager():New( 10, 10, oWnd, oToolBar, 580, 30,,,, .T., .T., .F., 14 )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- TPager wraps the Win32
SysPagercommon control. The pager provides arrow buttons that appear automatically when the child window exceeds the visible area. - Set
lHorz := .T.for horizontal paging (left/right arrows) or.F.for vertical (up/down arrows). lAutoScrollenables automatic scrolling when the user hovers the mouse near the pager edge, without clicking the buttons.lDragDropallows the user to click and drag to scroll the child window.- Call
RecalcSize()after changing the child window dimensions to refresh the pager layout. - The pager forwards mouse wheel messages to the child window when
ForwardMouse()is enabled.