I cannot get the control to start with an empty date.
dBegDate := ctod('')
REDEFINE DTPicker oBegDate VAR dBegDate ID 101 UPDATE OF oDlg
It always shows the checkbox checked when starting.
It is the same in the sample program "datetime.prg".
HB_FUNC( SETDATEPICK ) // ( hWnd, wYear, wMonth, wDay, GTD_NONE )
{
SYSTEMTIME sysTime;
sysTime.wYear = _parni( 2 );
sysTime.wMonth = _parni( 3 );
sysTime.wDay = _parni( 4 );
sysTime.wDayOfWeek = 0;
sysTime.wHour = 0;
sysTime.wMinute = 0;
sysTime.wSecond = 0;
sysTime.wMilliseconds = 0;
SendMessage( ( HWND ) _parnl( 1 ), DTM_SETSYSTEMTIME, _parni(5),
( LPARAM ) &sysTime );
}
METHOD SetDate( dDate, lEmpty ) INLINE SetDatePick( ::hWnd, Year( dDate ),;
Month( dDate ), Day( dDate ),;
If( lEmpty != nil .and. lEmpty, 1, 0 ) )
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HB_FUNC( SETDATEPICK ) // ( hWnd, wYear, wMonth, wDay, GTD_NONE )
{
SYSTEMTIME sysTime;
sysTime.wYear = hb_parni( 2 );
sysTime.wMonth = hb_parni( 3 );
sysTime.wDay = hb_parni( 4 );
sysTime.wDayOfWeek = 0;
sysTime.wHour = 0;
sysTime.wMinute = 0;
sysTime.wSecond = 0;
sysTime.wMilliseconds = 0;
SendMessage( ( HWND ) hb_parnl( 1 ), DTM_SETSYSTEMTIME, hb_parni(5),
( LPARAM ) &sysTime );
}
#pragma ENDDUMP
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <commctrl.h>
HB_FUNC( SETDATEPICK ) // ( hWnd, wYear, wMonth, wDay, GTD_NONE )
{
SYSTEMTIME sysTime;
sysTime.wYear = hb_parni( 2 );
sysTime.wMonth = hb_parni( 3 );
sysTime.wDay = hb_parni( 4 );
sysTime.wDayOfWeek = 0;
sysTime.wHour = 0;
sysTime.wMinute = 0;
sysTime.wSecond = 0;
sysTime.wMilliseconds = 0;
SendMessage( ( HWND ) hb_parnl( 1 ), DTM_SETSYSTEMTIME, hb_parni(5),
( LPARAM ) &sysTime );
}
#pragma ENDDUMP
#include "FiveWin.ch"
#include "constant.ch"
#define COLOR_WINDOW 5
#define COLOR_WINDOWTEXT 8
#define CS_DBLCLKS 8
#define DTS_SHOWNONE 0x0002
#ifdef __XPP__
#define Super ::TControl
#define New _New
#endif
//----------------------------------------------------------------------------//
CLASS TDatePick FROM TControl
CLASSDATA lRegistered
DATA lEmptyDate
METHOD New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, bValid, nClrFore,;
nClrBack, oFont, lDesign, oCursor, lPixel, cMsg, lUpdate,;
bWhen, bChange, nHelpId,lEmp) 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 SetDate( dDate ) // Modificado fgondi
METHOD GetDate() INLINE GetDatePick( ::hWnd )
METHOD LostFocus( hCtrl )
METHOD Change()
METHOD Changed() INLINE ( Eval( ::bSetGet, ::GetDate() ), ::Change() )
METHOD Refresh() INLINE ::SetDate( Eval( ::bSetGet ) )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, bValid, nClrFore,;
nClrBack, oFont, lDesign, oCursor, lPixel, cMsg, lUpdate,;
bWhen, bChange, nHelpId, lEmp ) Class TDatePick
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.,;
lEmp := .t.
::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
::lEmptyDate := lEmp
::lEmptyDate := .t.
if !lEmp
::nStyle = nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP,;
If( lDesign, WS_CLIPSIBLINGS, 0 ) )
else
::nStyle = nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP, DTS_SHOWNONE,;
If( lDesign, WS_CLIPSIBLINGS, 0 ) )
endif
::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 TDatePick
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
::lEmptyDate := .t.
InitCommon()
::Register()
oWnd:DefControl( Self )
return Self
METHOD Initiate( hDlg ) Class TDatePick
Super:Initiate( hDlg )
::cText = Eval( ::bSetGet )
return nil
METHOD cText( uVal ) CLASS TDatePick
if PCount() == 1
Eval( ::bSetGet, uVal )
::SetDate( uVal )
::Refresh()
::Change()
endif
return ::GetDate()
//---------------------------------------------------------------------------//
// Controlo si la fecha esta vacia para quitar la marca del checkbox incluido en el campo
// El quinto parametro indica el estado del checkbox. 0 Marcado, 1 Desmarcado.
METHOD SetDate( dDate ) CLASS TDatePick
local dShow
local dDat := dDate
if empty( dDate )
dDat := if( !::lEmptyDate, date(), dDate )
endif
dShow := dDat
SetDatePick( ::hWnd, Year( dShow ), Month( dShow ), Day( dShow ), 0 )
if Empty(dDate)
SetDatePick( ::hWnd, Year( dShow ), Month( dShow ), Day( dShow ), 1 )
endif
return Self
METHOD LostFocus( hCtrl ) CLASS TDatePick
Eval( ::bSetGet, ::cText )
return Super:LostFocus( hCtrl )
METHOD Change() CLASS TDatePick
if ::bChange != nil
Eval( ::bChange, Self )
endif
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 41 guests