TUpDown
Source: source/classes/tupdown.prg
Inherits from: TControl
TUpDown wraps the Win32 up-down common control, also known as a spinner or buddy control. It is typically paired with a TGet field to provide increment/decrement arrow buttons that automatically update the buddy's value within a configurable range.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
nMin | Numeric | Minimum value of the spinner range |
nMax | Numeric | Maximum value of the spinner range |
nPos | Numeric | Current spinner position |
oBuddy | Object | The buddy control (usually a TGet) linked to this spinner |
lWrap | Logical | Wrap around when reaching the range boundary |
nAlign | Numeric | Alignment relative to the buddy: 0=right, 1=left |
Methods
| Method | Description |
|---|---|
New( nRow, nCol, oWnd, oBuddy, nW, nH, nMin, nMax, nPos ) | Create a new up-down control |
SetPos( n ) | Set the spinner position to n |
GetPos() | Return the current spinner position |
SetRange( nMin, nMax ) | Set the minimum and maximum range values |
SetBuddy( oBuddy ) | Attach a buddy control to the spinner |
GetBuddy() | Return the currently attached buddy control |
Example: Spinner Linked to a GET Field
#include "FiveWin.ch"
function Main()
local oWnd, oGet, oSpinner, nVal := 5
DEFINE WINDOW oWnd TITLE "Quantity" SIZE 300, 150
@ 40, 20 GET oGet VAR nVal SIZE 60, 20 OF oWnd PICTURE "999"
@ 38, 80 UPDOWN oSpinner BUDDY oGet ;
RANGE 1, 100
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- The buddy control is automatically set as the window specified in the
BUDDYclause. The up-down control positions itself adjacent to the buddy. - When
lWrapis set to.T., clicking up atnMaxwraps tonMinand vice versa. - The
RANGEclause sets bothnMinandnMaxsimultaneously. - TUpDown uses the Win32
UDS_SETBUDDYINTstyle to automatically update the buddy control's displayed value.