Repository navigation
SysWin Gui Pager
Home › All Categories › sys/win › sys/win/gui › Pager
Sets what a pager control scrolls, and reads and sets its position, buttons and colours.
A pager control is a strip that holds one window too wide (or too tall) for the space it is
given, typically a toolbar, and shows arrow buttons at its ends that scroll the window through
it. Create one with CWindow.AddControl( "Pager", ... ), which makes a horizontal pager
(PGS_HORZ); then create the contained window as a child of the pager and hand it over with
SetChild. Every function here takes the pager's handle first and is written with
the namespace: Pager.SetChild( hPager, hToolbar ).
The pager does not measure the contained window. It asks its parent with a WM_NOTIFY
carrying PGN_CALCSIZE: the parent fills in iWidth (or iHeight) of the NMPGCALCSIZE with
the window's full size. RecalcSize asks again after the contents change.
Positions and sizes are in pixels.
#import "sys/win"
#import "sys/win/gui"
using win, guiA 300-pixel pager holding a label 900 pixels wide; the arrows scroll the label, and each scroll puts the position it starts from in the caption.
#import "sys/win"
#import "sys/win/gui"
using win, gui
const IDC_PAGER = 101
const CONTENT_WIDTH = 900
declare function WndProc( byval hwnd as HWND, byval uMsg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
function main() as long
SetProcessDpiAwareness( PROCESS_SYSTEM_DPI_AWARE )
dim pWindow as CWindow = "PagerDemo"
dim hWin as HWND = pWindow.Create( NULL, "Pager", @WndProc )
pWindow.SetClientSize( 340, 80 )
pWindow.Center()
dim hPager as HWND = pWindow.AddControl( "Pager", hWin, IDC_PAGER, "", 20, 25, 300, 30 )
dim hLabel as HWND = pWindow.AddControl( "Label", hPager, -1, _
"A long line of text that is far wider than the pager, so the pager shows its arrows.", _
0, 0, CONTENT_WIDTH, 30 )
Pager.SetButtonSize( hPager, 16 )
Pager.SetChild( hPager, hLabel )
return pWindow.DoEvents( SW_NORMAL )
end function
function WndProc( byval hwnd as HWND, byval uMsg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
select case uMsg
case WM_NOTIFY
dim pnmh as NMHDR ptr = cast( NMHDR ptr, lParam )
if pnmh->idFrom = IDC_PAGER then
select case pnmh->code
case PGN_CALCSIZE
dim pcs as NMPGCALCSIZE ptr = cast( NMPGCALCSIZE ptr, lParam )
if pcs->dwFlag = PGF_CALCWIDTH then pcs->iWidth = CONTENT_WIDTH
case PGN_SCROLL
SetWindowText( hwnd, "Scrolling from " & Pager.GetPos( pnmh->hwndFrom ) )
end select
end if
return 0
case WM_DESTROY
PostQuitMessage( 0 )
return 0
end select
return DefWindowProcW( hwnd, uMsg, wParam, lParam )
end function
end main()| Function | Does |
|---|---|
| SetChild | Sets the window the pager scrolls. |
| RecalcSize | Makes the pager ask for the contained window's size again. |
| GetPos | Returns the scroll position. |
| SetPos | Scrolls to a position. |
| GetButtonSize | Returns the size of the arrow buttons. |
| SetButtonSize | Sets the size of the arrow buttons. |
| GetButtonState | Returns whether an arrow button is shown, greyed or pressed. |
| GetBorder | Returns the border around the contained window. |
| SetBorder | Sets the border around the contained window. |
| GetBkColor | Returns the background colour. |
| SetBkColor | Sets the background colour. |
| ForwardMouse | Passes mouse moves on to the contained window. |
| GetDropTarget | Returns the pager's IDropTarget. |
sub SetChild( byval hPager as HWND, byval hwndChild as HWND )Makes hwndChild the window the pager scrolls. It does not change the window's parent: create
the window as a child of the pager. The pager then sends PGN_CALCSIZE to find its size.
Example
dim pWindow as CWindow ptr = CWindowPtr( hwnd )
Pager.SetChild( hCtrl, pWindow->AddControl( "Toolbar", hCtrl, 300 ) )Microsoft Learn: PGM_SETCHILD
sub RecalcSize( byval hPager as HWND )Makes the pager send PGN_CALCSIZE again and lay itself out for the size it is given. Call it
after the contained window grows or shrinks, for instance after buttons are added to a toolbar.
Example
Pager.RecalcSize( hCtrl )Microsoft Learn: PGM_RECALCSIZE
function GetPos( byval hPager as HWND ) as longReturns the scroll position, in pixels from the start of the contained window: 0 when it is not scrolled.
Example
print "scrolled by"; Pager.GetPos( hCtrl ); " pixels"Microsoft Learn: PGM_GETPOS
function SetPos( byval hPager as HWND, byval iPos as long ) as longScrolls the contained window to position iPos, in pixels.
Returns the control's reply, which carries no information.
Example
Pager.SetPos( hCtrl, 0 ) ' back to the startMicrosoft Learn: PGM_SETPOS
function GetButtonSize( byval hPager as HWND ) as longReturns the size of the arrow buttons in pixels: their width for a horizontal pager, their height for a vertical one. It is 12 unless changed.
Example
print "arrow buttons:"; Pager.GetButtonSize( hCtrl ); " pixels"Microsoft Learn: PGM_GETBUTTONSIZE
function SetButtonSize( byval hPager as HWND, byval iSize as long ) as longSets the size of the arrow buttons in pixels.
Returns the previous size.
Example
Pager.SetButtonSize( hCtrl, 16 )Microsoft Learn: PGM_SETBUTTONSIZE
function GetButtonState( byval hPager as HWND, byval iButton as long ) as DWORDReturns the state of one arrow button: iButton is PGB_TOPORLEFT or PGB_BOTTOMORRIGHT.
Returns PGF_INVISIBLE, PGF_NORMAL, PGF_GRAYED, PGF_DEPRESSED or PGF_HOT.
Example
if Pager.GetButtonState( hCtrl, PGB_BOTTOMORRIGHT ) = PGF_INVISIBLE then print "scrolled to the end"Microsoft Learn: PGM_GETBUTTONSTATE
function GetBorder( byval hPager as HWND ) as longReturns the width of the border drawn around the contained window, in pixels; 0 unless changed.
Example
print "border:"; Pager.GetBorder( hCtrl )Microsoft Learn: PGM_GETBORDER
function SetBorder( byval hPager as HWND, byval iBorder as long ) as longSets the width of the border around the contained window, in pixels.
Returns the previous border.
Example
Pager.SetBorder( hCtrl, 2 )Microsoft Learn: PGM_SETBORDER
function GetBkColor( byval hPager as HWND ) as COLORREFReturns the background colour; the button-face colour unless changed.
Example
print "background: &h"; hex( Pager.GetBkColor( hCtrl ) )Microsoft Learn: PGM_GETBKCOLOR
function SetBkColor( byval hPager as HWND, byval clr as COLORREF ) as COLORREFSets the background colour, seen around and behind the contained window.
Returns the previous colour.
Example
Pager.SetBkColor( hCtrl, BGR( 255, 255, 255 ) )Microsoft Learn: PGM_SETBKCOLOR
sub ForwardMouse( byval hPager as HWND, byval bForward as boolean )With bForward true the pager passes WM_MOUSEMOVE on to the contained window, which a
toolbar needs to show hot buttons; false stops it.
Example
Pager.ForwardMouse( hCtrl, true )Microsoft Learn: PGM_FORWARDMOUSE
sub GetDropTarget overload( byval hPager as HWND, byval ppdt as IDropTarget ptr ptr )
function GetDropTarget overload( byval hPager as HWND ) as IDropTarget ptrGets the pager's IDropTarget interface, for a program that handles drag and drop over the
pager. The pointer holds a reference: call Release on it when done.
Returns the interface pointer, or NULL (second form).
Example
dim pdt as IDropTarget ptr = Pager.GetDropTarget( hCtrl )
if pdt then pdt->lpVtbl->Release( pdt )Microsoft Learn: PGM_GETDROPTARGET
- sys/win/gui
-
CWindow for
AddControl( "Pager", ... ) - ToolBar, the usual contents of a pager
- Rebar
-
gui macros and helpers for reading
WM_NOTIFY
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing