TTimePick
Fonte: source/classes/ttmpicke.prg
Inherits from: TControl
TTimePick wraps the Windows date and time picker common control configured for time-only selection. It provides an intuitive interface for selecting hours, minutes, and seconds using up-down spinners or direct keyboard input. The control operates on a time string in "HH:MM:SS" format.
Command Syntax
@ nRow, nCol TMPICKER oTmp VAR cTime SIZE nW, nH PIXEL OF oWnd ;
ON CHANGE bBlock
Methods
| Method | Description |
|---|---|
New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, bValid, nClrFore, nClrBack, oFont, lDesign, oCursor, lPixel, cMsg, lUpdate, bWhen, bChange, nHelpId ) | Create a new TTimePick control |
ReDefine( nId, bSetGet, oWnd, nHelpId, nClrFore, nClrBack, oFont, oCursor, cMsg, lUpdate, bWhen, bValid, bChanged ) | Redefine from dialog resource |
SetTime( cHour ) | Set the time value using a string in "HH:MM:SS" format |
GetTime() | Retrieve the current time as a formatted string |
cText( uVal ) | Get or set the formatted time text (SETGET accessor) |
Refresh() | Refresh the control from the bound variable |
Change() | Execute the bChange code block |
Example: Time Picker with Change Callback
#include "FiveWin.ch"
function Main()
local oWnd, oTmp, cTime := Time() // e.g. "14:25:30"
DEFINE WINDOW oWnd TITLE "Time Picker Demo" SIZE 300, 200
@ 40, 30 TMPICKER oTmp VAR cTime SIZE 100, 22 PIXEL OF oWnd ;
ON CHANGE MsgInfo( cTime, "Time Changed" )
@ 100, 30 BUTTON "&Get Time" SIZE 80, 25 PIXEL OF oWnd ;
ACTION MsgInfo( oTmp:GetTime(), "Current Time" )
@ 100, 130 BUTTON "&Set 12:00" SIZE 80, 25 PIXEL OF oWnd ;
ACTION oTmp:SetTime( "12:00:00" )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- TTimePick wraps the same Win32
SysDateTimePick32common control as TDatePick but configures it for time-only display (hours:minutes:seconds). - The bound variable is a character string in
"HH:MM:SS"format (24-hour clock). Use theVAR cTimecommand syntax to bind it automatically. - Time navigation is done via the up/down spinner arrows on the right side of the control, which increment or decrement the currently focused time segment (hours, minutes, or seconds).
- Users can also click directly on a segment (hours, minutes, or seconds) and type a new value.
- The
cTextSETGET accessor allows getting or setting the time as a string in a different format if needed, though the control internally uses the system time format.