I wish change the color of a cell ( first column) of a xbrowse

to change color it control if the number day is on a archive of Holyday ( feste.dbf) I converte into a array aFeste
and if found the number day put the background color on the first cell
It make the command but lose the color , if the final user select a record it return the back color
I tried to use a refresh but i not run ok
Any solution ?
this is the source code of the test ( it create the dbf also)
On this test I set the december mounth and I wish show the Holydays of the december

to change color it control if the number day is on a archive of Holyday ( feste.dbf) I converte into a array aFeste
and if found the number day put the background color on the first cell
It make the command but lose the color , if the final user select a record it return the back color
I tried to use a refresh but i not run ok
Any solution ?
this is the source code of the test ( it create the dbf also)
On this test I set the december mounth and I wish show the Holydays of the december
#include "fivewin.ch"
#include "constant.ch"
#Define COLORE_DOMENICHE Rgb(255,218,185) // COLORE ROSA
#Define COLORE_NATALE nRGB( 203, 225, 252 )
#Define COLORE_PASQUA CLR_HGRAY
#Define COLORE_PATRONO CLR_GREEN
#Define COLORE_PASQUETTA CLR_GRAY
REQUEST HB_LANG_IT
REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO
static aFeste
Function Test()
Local nMese:= 12
Local nAnno :="2014"
Local dDate
Local nDays:= 31
Local aGiorni:= {}
Local PGiorno
Local oBrw
Local nBottom := 29
Local nRight := 22
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
HB_LangSelect("IT")
SET DATE FORMAT "dd-mm-yyyy"
SET DELETED ON
SET CENTURY ON
SET EPOCH TO year( date() ) - 20
SET MULTIPLE OFF
RddSetDefault( "DBFCDX" )
// create the array feste
Crea_Festivita()
aFeste := {}
if ! Db_Open_Root(".\FESTE","FS")
return nil
endif
SELECT FS
FS->(DbSetOrder(1))
FS->(DbGoTop())
DO WHILE ! FS->(EoF())
AAdd( aFeste, {strzero(FS->GIORNO,2),str(FS->MESE),FS->DESCRI })
FS->(DbSkip())
ENDDO
// create the calendar
dDate:= CTOD("01/"+strzero(nMese,2)+"/"+nAnno)
FOR n=1 to nDays
PGiorno:= CTOD(strzero(n,2)+"/"+StrZero(Month(dDate),2)+"/"+StrZero(Year(dDate),4))
AADD(aGiorni,{ strzero(n,2)+" "+Left(cDow(PGiorno), 2) } )
NEXT
DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -12
DEFINE DIALOG oDlg ;
TITLE "Visualizzazione cartellino del mese di Dicembre" ;
SIZE nWidth, nHeight PIXEL
@ 0,0 XBROWSE oBrw OF oDlg ;
COLUMNS 1 ;
HEADERS "Giorno" ;
COLSIZES 75 ;
ARRAY aGiorni LINES FASTEDIT CELL SIZE -10,-10 PIXEL
// colonna colore per domenica e festività
for nI = 1 to 1
oBrw:aCols[ nI ]:bClrStd :=ChangeColor( oBrw,nI,nMese)
next
WITH OBJECT oBrw
:lHScroll := .f.
:lFooter:=.t.
:MakeTotals()
:CreateFromCode()
END
ACTIVATE DIALOG oDlg center
return nil
static function ChangEColor( oBrw, n,nMese ,afeste)
return {|| { CLR_BLACK, ColorCellNew( oBrw:aRow[ n ],nMese) } }
static function ColorCellNew( ctesto,nMese)
Local nColor := GetSysColor( 5 )
local uDito :=0
Local n
IF !ctesto = Nil
asort(aFeste)
For n=1 to len(aFeste)
IF nMese=val(aFeste[n][2])
IF LEFT(alltrim(ctesto),2)=alltrim(aFeste[n][1])
nColor :=COLORE_DOMENICHE
else
nColor := GetSysColor( 5 )
ENDIF
ENDIF
Next
ENDIF
return nColor
function Db_Open_Root(cDbf,cAlias)
if file( cDbf + ".dbf" )
USE &(cDbf+".dbf") ;
ALIAS &(cAlias) NEW
else
MsgStop( i18n( "Non si è trovato l'archivio dei dati." ) + CRLF + ;
i18N( "Per favore controlla la configurazione") + CRLF + ;
i18N( "e indicizza gli archivi dell'applicazione." ) )
return .f.
END if
if NetErr()
msgStop( i18n( "Errore nell'aprire un archivio" ) + CRLF + ;
i18n( "Per favore caricare di nuovo l'applicazione." ) )
DbCloseAll()
return .f.
endif
return .t.
Function Crea_Festivita()
DbCreate('FS', {{'Giorno' , 'N', 2, 0} ,;
{'Mese' , 'N', 2, 0} ,;
{'Descri' , 'C', 40, 0} }, 'DBFCDX')
close all
use &('FS') alias FS new
select Fs
if FILE('FESTE.DBF')
delete file &('FESTE.cdx')
append from &('FESTE')
dbcommitall()
close all
delete file &('FESTE.dbf')
endif
close all
rename &('FS.dbf') to &('FESTE.DBF')
DbCloseAll()
if ! Db_Open_Root(".\FESTE","FS")
return nil
endif
SELECT FS
IF FS->(OrdKeyCount())=0
APPEND BLANK
REPLACE GIORNO WITH 1
REPLACE MESE WITH 1
REPLACE DESCRI WITH "Capodanno"
APPEND BLANK
REPLACE GIORNO WITH 6
REPLACE MESE WITH 1
REPLACE DESCRI WITH "Epifania"
APPEND BLANK
REPLACE GIORNO WITH 25
REPLACE MESE WITH 4
REPLACE DESCRI WITH "Anniversario della liberazione"
APPEND BLANK
REPLACE GIORNO WITH 1
REPLACE MESE WITH 5
REPLACE DESCRI WITH "Festa del Lavoro"
APPEND BLANK
REPLACE GIORNO WITH 2
REPLACE MESE WITH 6
REPLACE DESCRI WITH "Festa della Repubblica"
APPEND BLANK
REPLACE GIORNO WITH 15
REPLACE MESE WITH 8
REPLACE DESCRI WITH "Ferragosto"
APPEND BLANK
REPLACE GIORNO WITH 1
REPLACE MESE WITH 11
REPLACE DESCRI WITH "Festa di tutti i santi"
APPEND BLANK
REPLACE GIORNO WITH 8
REPLACE MESE WITH 12
REPLACE DESCRI WITH "Immacolata Concezione"
APPEND BLANK
REPLACE GIORNO WITH 19
REPLACE MESE WITH 12
REPLACE DESCRI WITH "San Berardo"
APPEND BLANK
REPLACE GIORNO WITH 25
REPLACE MESE WITH 12
REPLACE DESCRI WITH "Natale"
APPEND BLANK
REPLACE GIORNO WITH 26
REPLACE MESE WITH 12
REPLACE DESCRI WITH "Santo Stefano"
Endif
INDEX ON FS->MESE TAG FS TO FESTE
DbCloseAll()
RETURN NILSince from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
