Una Disculpa por la tardanza.
Mejor se los pongo aquí, no es muy grande.
Code: Select all
#include "Fivewin.ch"
#include "TSBrowse.ch"
//--------------------------------------------------------------------------------------------------------------------//
Function CalAnual( dDate )
Local oDlg, oBrw, nCol, dFecha, nMonth, aLine, bBlock, nDia, nMes, nYear, ;
aCale := {}, ;
aMes := { "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic" }, ;
aSem := { "Mes", "Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab", ;
"Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab", ;
"Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab", ;
"Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab", ;
"Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab", "Dom", "Lun", "Mar", "Mie" }
Default dDate := Date()
SET DATE BRITISH
SET EPOCH TO Year( Date() ) - 70
SetKey( VK_UP, {|| If( GetKeyState( VK_CONTROL ), aSetCale( StoD( Str( --nYear, 4 ) + StrZero( nMes, 2 ) + ;
StrZero( nDia, 2 ) ), oBrw, oDlg ), Nil ) } )
SetKey( VK_DOWN, {|| If( GetKeyState( VK_CONTROL ), aSetCale( StoD( Str( ++nYear, 4 ) + StrZero( nMes, 2 ) + ;
StrZero( nDia, 2 ) ), oBrw, oDlg ), Nil ) } )
nYear := Year( dDate )
aCale := aSetCale( dDate )
nDia := AScan( aCale[ Month( dDate ) ], {|e,n| n > 1 .and. e == Day( dDate ) } )
DEFINE DIALOG oDlg TITLE Str( nYear ) SIZE 760, 210
@ 0, 0 BROWSE oBrw ARRAY aCale OF oDlg SIZE 385, 107 PIXEL CELLED ;
COLORS CLR_BLACK, {|r,c| If( c == 1, CLR_HGRAY, CLR_WHITE ) }, ;
{ |c| If( c== oBrw:nCell, CLR_WHITE, CLR_BLACK ) }, ;
{ |c| If( c== oBrw:nCell, CLR_BLACK, CLR_HGRAY ) }, CLR_WHITE, CLR_BLACK
For nCol := 1 To 38
bBlock := bDetachable( oBrw, nCol )
ADD COLUMN TO oBrw DATA bBlock TITLE aSem[ Min( 42, nCol ) ] SIZE 20 ALIGN DT_RIGHT
oBrw:aColumns[ nCol ]:bGotFocus := {|| Eval( oBrw:bChange ) }
Next
With Object oBrw
:lNoChangeOrd := .T.
:lNoHSCroll := .T.
:lInitGoTop := .F.
:aColumns[ 1 ]:lFixLite := .T.
:nFreeze := 1
:lLockFreeze := .T.
:nRowPos := Month( dDate )
:bChange := { || If( Empty( oBrw:aArray[ oBrw:nAt, oBrw:nCell ] ), dFecha := CtoD( "//" ), ( ;
dFecha := Ctod( StrZero( nDia := oBrw:aArray[ oBrw:nAt, oBrw:nCell ], 2 ) + "/" + ;
StrZero( nMes := oBrw:nAt, 2 ) + "/" + Str( nYear ) ), oBrw:DrawHeaders() ) ) }
End With
ACTIVATE DIALOG oDlg CENTER ON INIT oBrw:HiliteCell( nDia )
Return dFecha
//--------------------------------------------------------------------------------------------------------------------//
Static Function bDetachable( oBrw, nCol )
Return { |uVar| If( uVar == Nil, oBrw:aArray[ oBrw:nAt, nCol ], oBrw:aArray[ oBrw:nAt, nCol ] := uVar ) }
//--------------------------------------------------------------------------------------------------------------------//
Static Function aSetCale( dDate, oBrw, oDlg )
Local aLine, nMonth, nCol, dFecha, nYear, nDia, ;
aMes := { "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic" }, ;
aArr := {}
nYear := Year( dDate )
For nMonth := 1 To 12
dFecha := CtoD( "01/" + StrZero( nMonth, 2 ) + "/" + Str( nYear ) )
nCol := DoW( dFecha )
aLine := Array( 39 )
While Month( dFecha ) == nMonth
aLine[ nCol++ ] := Day( dFecha )
dFecha ++
EndDo
AAdd( aArr, aLine )
Next
For nCol := 1 To Len( aArr )
ASize( aArr[ nCol ], 40 )
AIns( aArr[ nCol ], 1 )
aArr[ nCol, 1 ] := aMes[ nCol ]
Next
If oBrw != Nil
nDia := AScan( aArr[ Month( dDate ) ], {|e,n| n > 1 .and. e == Day( dDate ) } )
oBrw:SetArray( aArr )
oBrw:nRowPos := Month( dDate )
oBrw:HiliteCell( nDia )
oDlg:SetText( Str( nYear, 4 ) )
EndIf
Return aArr
//--------------------------------------------------------------------------------------------------------------------//
Static Function StoD( cAnsiDate )
Local cFormat := Upper( Set( _SET_DATEFORMAT ) ), ;
cYear := SubStr( cAnsiDate, 1, 4 ), ;
cMon := SubStr( cAnsiDate, 5, 2 ), ;
cDay := SubStr( cAnsiDate, 7, 2 )
cFormat := StrTran( cFormat, "YYYY", cYear )
cFormat := StrTran( cFormat, "YY", Right( cYear, 2 ) )
cFormat := StrTran( cFormat, "MM", cMon )
cFormat := StrTran( cFormat, "DD", cDay )
Return CtoD( cFormat )
Saludos.