¿ Existe algun TIMEpicker ?
Algo parecido a DTPICKER pero para HH:MM:SS.
Es decir, para cambiar la hora como cuando accedemos a "Propiedades de Fecha y hora" de Windows.
Gracias.
#include "FiveWin.ch"
#include "constant.ch"
#define COLOR_WINDOW 5
#define COLOR_WINDOWTEXT 8
#define CS_DBLCLKS 8
#ifdef __XPP__
#define Super ::TControl
#define New _New
#endif
//----------------------------------------------------------------------------//
CLASS TTimePick FROM TControl
CLASSDATA lRegistered
METHOD New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, bValid, nClrFore,;
nClrBack, oFont, lDesign, oCursor, lPixel, cMsg, lUpdate,;
bWhen, bChange, nHelpId) CONSTRUCTOR
METHOD ReDefine( nId, bSetGet,oWnd, nHelpId, cMsg, lUpdate, bWhen, bValid) CONSTRUCTOR
METHOD cText( cText ) SETGET
METHOD cToChar() INLINE Super:cToChar( "SysDateTimePick32" )
METHOD Initiate( hDlg )
METHOD SetTime( cHour )
METHOD GetTime() INLINE GetTimePick( ::hWnd )
METHOD LostFocus( hCtrl )
METHOD Change()
METHOD Changed() INLINE ( Eval( ::bSetGet, ::GetTime() ), ::Change() )
METHOD Refresh() INLINE ::SetTime( Eval( ::bSetGet ) )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, bValid, nClrFore,;
nClrBack, oFont, lDesign, oCursor, lPixel, cMsg, lUpdate,;
bWhen, bChange, nHelpId) Class TTimePick
DEFAULT nRow := 0, nCol := 0,;
oWnd := GetWndDefault(),;
nWidth := 100,;
nHeight := If( oFont != nil, oFont:nHeight, 22 ),;
nClrFore := GetSysColor( COLOR_WINDOWTEXT ),;
nClrBack := GetSysColor( COLOR_WINDOW ),;
oFont := oWnd:oFont,;
nHelpId := 100,;
lDesign := .f.,;
lPixel := .f.,;
lUpdate := .f.
::cCaption = ""
::nTop = nRow * If( ! lPixel, BTN_CHARPIX_H, 1 )
::nLeft = nCol * If( ! lPixel, BTN_CHARPIX_W, 1 )
::nBottom = ::nTop + nHeight
::nRight = ::nLeft + nWidth
::nHelpId = nHelpId
::oWnd = oWnd
::oFont = oFont
::bSetGet = bSetGet
::nStyle = nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP,;
If( lDesign, WS_CLIPSIBLINGS, 0 ) )
::nId = ::GetNewId()
::lDrag = lDesign
::lCaptured = .f.
::cMsg = cMsg
::lUpdate = lUpdate
::bWhen = bWhen
::bValid = bValid
::bChange = bChange
InitCommon()
if ! Empty( oWnd:hWnd )
::Create( "SysDateTimePick32" )
oWnd:AddControl( Self )
if oFont != nil
::SetFont( oFont )
endif
else
oWnd:DefControl( Self )
endif
if lDesign
::CheckDots()
endif
return Self
//----------------------------------------------------------------------------//
METHOD ReDefine( nId, bSetGet, oWnd, nHelpId, nClrFore, nClrBack,;
oFont, oCursor, cMsg, lUpdate, bWhen, bValid, bChanged ) Class TTimePick
DEFAULT oWnd := GetWndDefault(),;
nClrFore := GetSysColor( COLOR_WINDOWTEXT ),;
nClrBack := GetSysColor( COLOR_WINDOW ),;
lUpdate := .f.
::nId = nId
::hWnd = 0
::nHelpId = nHelpId
::oWnd = oWnd
::oFont = oFont
::oCursor = oCursor
::lCaptured = .f.
::lDrag = .f.
::cMsg = cMsg
::lUpdate = lUpdate
::bWhen = bWhen
::bValid = bValid
::bSetGet = bSetGet
::bChange = bChanged
InitCommon()
::Register()
oWnd:DefControl( Self )
return Self
//----------------------------------------------------------------------------//
METHOD Initiate( hDlg ) Class TTimePick
Super:Initiate( hDlg )
::cText = Eval( ::bSetGet )
return nil
//---------------------------------------------------------------------------//
METHOD cText( uVal ) CLASS TTimePick
if PCount() == 1
Eval( ::bSetGet, uVal )
::SetTime( uVal )
::Refresh()
::Change()
endif
return ::GetTime()
//---------------------------------------------------------------------------//
// Controlo si la hora esta vacia para quitar la marca del checkbox incluido en el campo
// Hay pasar una fecha para que valide la hora, por eso siempre paso la fecha de actual Date()
// El octavo parametro indica el estado del checkbox. 0 Marcado, 1 Desmarcado.
METHOD SetTime( cHour ) CLASS TTimePick
local cShow, nHora, nMinut, nSeg
cShow := if( Empty(cHour), Hora(), cHour )
nHora := Val(left(cShow, 2))
nMinut := Val(SubStr(cShow, 3, 2))
nSeg := Val(Right(cShow, 2))
SetTimePick( ::hWnd, Year( Date() ), Month( Date() ), Day( Date() ),;
nHora, nMinut, nSeg, 0 )
if Empty(cHour)
SetTimePick( ::hWnd, Year( Date() ), Month( Date() ), Day( Date() ),;
nHora, nMinut, nSeg, 1 )
endif
return self
//---------------------------------------------------------------------------//
METHOD LostFocus( hCtrl ) CLASS TTimePick
Eval( ::bSetGet, ::cText )
return Super:LostFocus( hCtrl )
//---------------------------------------------------------------------------//
METHOD Change() CLASS TTimePick
if ::bChange != nil
Eval( ::bChange, Self )
endif
return nil
//---------------------------------------------------------------------------//
FUNCTION Hora()
local nAux, nMin, nHor, nSec, cMin, cHor, cSec
nSec := Seconds()
nAux := Int(nSec) / 3600
nHor := Int(nAux)
nAux := (nAux - nHor) * 60
nMin := Int(nAux)
nSec := Int( (nAux - nMin) * 60 )
cHor := Padl( alltrim(str(nHor)), 2, '0')
cMin := Padl( alltrim(str(nMin)), 2, '0')
cSec := Padl( alltrim(str(nSec)), 2, '0')
return cHor + cMin + cSec
#define _WIN32_WINNT 0x0400
//#include <WinTen.h>
//#include <Windows.h>
//#include <ClipApi.h>
//#include <shlobj.h>
//#include <commctrl.h>
//---------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER SETTIMEPICK( PARAMS ) // ( hWnd, wYear, wMonth, wDay, wHour, wMinute, wSecond, GTD_NONE )
#else
CLIPPER SETTIMEPIC( PARAMS )
#endif
{
SYSTEMTIME sysTime;
sysTime.wYear = _parni( 2 );
sysTime.wMonth = _parni( 3 );
sysTime.wDay = _parni( 4 );
sysTime.wDayOfWeek = 0;
sysTime.wHour = _parni( 5 );
sysTime.wMinute = _parni( 6 );
sysTime.wSecond = _parni( 7 );
sysTime.wMilliseconds = 0;
SendMessage( ( HWND ) _parnl( 1 ), DTM_SETSYSTEMTIME, _parni( 8),
( LPARAM ) &sysTime );
}
//---------------------------------------------------------------------------//
#ifdef __HARBOUR__
CLIPPER GETTIMEPICK( PARAMS ) // ( hWnd ) --> dDate
#else
CLIPPER GETTIMEPICK( PARAMS )
#endif
{
SYSTEMTIME st;
char hour[ 7 ];
SendMessage( ( HWND ) _parnl( 1 ), DTM_GETSYSTEMTIME, 0, ( LPARAM ) &st );
wsprintf( hour, "%2i%02i%02i", st.wHour, st.wMinute, st.wSecond );
_retc( hour );
}
//----------------------------------------------------------------------------/
C:\TTimePick.prg(223) Error E0030 Syntax error: "syntax error at 'SETTIMEPICK'"
C:\TTimePick.prg(229) Error E0030 Syntax error: "syntax error at 'SYSTIME'"
C:\TTimePick.prg(238) Error E0030 Syntax error: "syntax error at '='"
C:\TTimePick.prg(239) Error E0030 Syntax error: "syntax error at '_PARNL'"
C:\TTimePick.prg(241) Error E0030 Syntax error: "syntax error at '&SYSTIME'"
C:\TTimePick.prg(246) Error E0030 Syntax error: "syntax error at 'GETTIMEPICK'"
C:\TTimePick.prg(253) Error E0030 Syntax error: "syntax error at 'ST'"
C:\TTimePick.prg(256) Error E0030 Syntax error: "syntax error at '_PARNL'"
C:\TTimePick.prg(258) Error E0030 Syntax error: "syntax error at '}'"
#ifdef __HARBOUR__
CLIPPER SETTIMEPICK( PARAMS ) // LINEA 223
#else
CLIPPER SETTIMEPIC( PARAMS )
#endif
#command @ <nRow>, <nCol> TMPICKER [ <oDTPicker> VAR ] <uVar> ;
[ <dlg: OF, WINDOW, DIALOG> <oWnd> ] ;
[ VALID <ValidFunc> ] ;
[ <color:COLOR,COLORS> <nClrFore> [,<nClrBack>] ] ;
[ SIZE <nWidth>, <nHeight> ] ;
[ FONT <oFont> ] ;
[ <design: DESIGN> ] ;
[ CURSOR <oCursor> ] ;
[ <pixel: PIXEL> ] ;
[ MESSAGE <cMsg> ] ;
[ <update: UPDATE> ] ;
[ WHEN <uWhen> ] ;
[ ON CHANGE <uChange> ] ;
[ <help:HELPID, HELP ID> <nHelpId> ] ;
=> ;
[ <oDTPicker> := ] TTimePick():New( <nRow>, <nCol>, bSETGET(<uVar>),;
[<oWnd>], <nWidth>, <nHeight>, <{ValidFunc}>,;
<nClrFore>, <nClrBack>, <oFont>, <.design.>,;
<oCursor>, <.pixel.>, <cMsg>, <.update.>, <{uWhen}>,;
[\{|nKey, nFlags, Self| <uChange>\}], <nHelpId> )
#xcommand REDEFINE TMPICKER [ <oTMPicker> VAR ] <uVar> ;
[ ID <nId> ] ;
[ <dlg: OF, WINDOW, DIALOG> <oDlg> ] ;
[ <help:HELPID, HELP ID> <nHelpId> ] ;
[ <color: COLOR,COLORS> <nClrFore> [,<nClrBack>] ] ;
[ FONT <oFont> ] ;
[ CURSOR <oCursor> ] ;
[ MESSAGE <cMsg> ] ;
[ <update: UPDATE> ] ;
[ WHEN <uWhen> ] ;
[ VALID <uValid> ] ;
[ ON CHANGE <uChange> ] ;
=> ;
[ <oTMPicker> := ] TTimePick():Redefine( <nId>, bSETGET(<uVar>),;
<oDlg>, <nHelpId>, <nClrFore>, <nClrBack>, <oFont>, <oCursor>,;
<cMsg>, <.update.>, <{uWhen}>, <{uValid}>,;
[\{|nKey, nFlags, Self| <uChange>\}] )
#ifdef __HARBOUR__
CLIPPER SETTIMEPICK( PARAMS ) // LINEA 223
#else
CLIPPER SETTIMEPIC( PARAMS )
#endif
#ifdef __HARBOUR__
HB_FUNC( SETTIMEPICK ) // LINEA 223
#else
HB_FUNC( SETTIMEPIC )
#endif
CONTROL "", 204, "SysDateTimePick32", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 210, 20, 50-2, 13
CONTROL "", 204, "SysDateTimePick32", 0 | DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 210, 20, 50-2, 13
fgondi wrote:El recurso para el formato hora es así:
CONTROL "", 204, "SysDateTimePick32", 0 | DTS_TIMEFORMAT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 210, 20, 50-2, 13
#define DTS_UPDOWN 0x0001 // use UPDOWN instead of MONTHCAL
#define DTS_SHOWNONE 0x0002 // allow a NONE selection
#define DTS_SHORTDATEFORMAT 0x0000 // use the short date format (app must forward WM_WININICHANGE messages)
#define DTS_LONGDATEFORMAT 0x0004 // use the long date format (app must forward WM_WININICHANGE messages)
#define DTS_TIMEFORMAT 0x0009 // use the time format (app must forward WM_WININICHANGE messages)
#define DTS_APPCANPARSE 0x0010 // allow user entered strings (app MUST respond to DTN_USERSTRING)
#define DTS_RIGHTALIGN 0x0020 // right-align popup instead of left-align it
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 59 guests