TTimePick

Source: 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

MethodDescription
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

See Also