each date control have a check VAlid function
@ 0.9,12 DTPICKER oDate1 VAR dDataIniziale OF oGrS1 SIZE 145,25 ;
UPDATE picture "ddd dd mmm yyyy" FONT oFontBig ;
ON CHANGE (if( dDataIniziale != othis:dDataIniziale,;
( SetDates( dDataIniziale,dDataFinale ),;
CHANGE_PLAN( dDataIniziale,dDataFinale,lShowNumeri,lshowPagamenti) ), ) ) ;
VALID ValidareData(dDataIniziale, dDataFinale )
Function ValidareData( dFechaIni, dFechaFin )
LOCAL lValid := .T.
IF ( dFechaIni > dFechaFin )
alert( "La data finale deve essere maggiore di quella iniziale " )
lValid := .F.
ENDIF
RETURN lValid
If the user press one of 4 buttons there is the check and run ok
But If the user change the date from
the datepick not execute the valid function and for a sample then I have the error
the datepick execute before and only the change command
Initially everything works except the ValidareData function that if a datepick is modified by the button inside the datepick
then it does not check the error ie it puts the second date less than the first
if you go to change the date with the mouse and click on the date with the ":" key on the keyboard you can scroll inside the datapick
then everything freezes
the first button does not show the popup menu and the "+" and "-" buttons do not perform the action
everything is blocked
here the test
Explain you before
the variables dDataIniziale,dDataFinale,lShowNumeri,lshowPagamenti on my application are data variables and so are public
because they are use on all application
on the test I put the variables as static
Code: Select all
#include "fivewin.ch"
#include "constant.ch"
#include "ribbon.ch"
#include "dtpicker.ch"
Static dDataIniziale,dDataFinale,lShowNumeri,lshowPagamenti //are data of Tapplication
function main()
local oRBar
local oWnd
local cCursor:= TCursor():New(,'HAND')
local aRbPrompts:={"Spiaggia","Planner","Gestione","Stampe","Visualizza","Configurazione","Strumenti"}
local nAltezzaRibbon:= 132
local aBtnfw :={ FW_BmpPlus(), FW_BmpMinus() }
local oDate1, oDate2
local oGrS1,oFontBig
local oBtns[6]
Local cSection:= "Stagioni"
Local nAnno := year(date())
local cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + "test.ini"
Local dBassa1 := GetIni( cIniFile, cSection, "BASSA1", "17.05." ) +ltrim(str(nAnno ))
Local dBassa4 := GetIni( cIniFile, cSection, "BASSA4", "20.09." ) +ltrim(str(nAnno ))
Local dDatastart:= date()
Local dDataEnd:= date()
dDataIniziale := date() //public data
dDataFinale := date() //public data
lShowNumeri := .t. //public data
lshowPagamenti := .t. //public data
SET DATE TO ITALIAN
dBassa1 := CTOD( dBassa1 )
dBassa4 := CTOD( dBassa4 )
DEFINE FONT oFontBig NAME "VERDANA" SIZE 0,-10
DEFINE WINDOW oWnd TITLE "RibbonBar Test " + FWVERSION from 1,1 to 600,600 pixel //brush oBrush1
oRBar := TRibbonBar():New(oWnd, aRbPrompts,,,,nAltezzaRibbon,22,CLR_WHITE,RGB(165,186,204),,,,,,,,.T.,)
ADD GROUP oGrS1 RIBBON oRbar TO OPTION 1 WIDTH 480 PROMPT "Periodo da visualizzare"
@ 5,5 ADD BUTTON oBtns[1] prompt "Selezione"+CRLF+"Calendario" BITMAP "TOOLBAR_CALENDAR" ;
GROUP oGrS1 SIZE 65,85 top ROUND SPLITPOPUP;
MENU MenuPopDate(@dDatastart ,@dDataEnd,@oDate1,@oDate2,dBassa1,dBassa4) ;
TOOLTIP "Selezione calendario e periodi "
@ 0.9,12 DTPICKER oDate1 VAR dDatastart OF oGrS1 SIZE 145,25 ;
UPDATE picture "ddd dd mmm yyyy" FONT oFontBig ;
ON CHANGE (if( dDatastart != dDataIniziale,;
( SetDates( dDatastart,dDataEnd ),;
CHANGE_PLAN( dDatastart,dDataEnd,lShowNumeri,lshowPagamenti) ), ) ) ;
VALID ValidareData(dDatastart,dDataEnd )
@ 0.9,40 DTPICKER oDate2 VAR dDataEnd OF oGrS1 SIZE 145,25 ;
UPDATE picture "ddd dd mmm yyyy" FONT oFontBig ;
ON CHANGE (if( dDataEnd != dDataFinale,;
( SetDates( dDatastart,dDataEnd ),;
CHANGE_PLAN( dDatastart,dDataEnd,lShowNumeri,lshowPagamenti) ), ) ) ;
VALID ValidareData(dDatastart,dDataEnd )
@ 45,72 ADD BUTTON oBtns[2] ;
BITMAP aBtnfw[2] ;
GROUP oGrS1 SIZE 28,25;// 60,25 ;
ACTION ( dDataIniziale--,oDate1:REFRESH(),;
EVAL( oDate1:bchange)) BORDER
@ 45,188 ADD BUTTON oBtns[3] ;
BITMAP aBtnfw[1] ;
GROUP oGrS1 SIZE 28,25; // 60,25 ;
ACTION (IF( dDataIniziale<dDataFinale,dDataIniziale++,(dDataIniziale++,dDataFinale++)),;
oDate1:REFRESH(),oDate2:REFRESH(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange)) BORDER
@ 45,241 ADD BUTTON oBtns[4] ;
BITMAP aBtnfw[2] ; //"BTN_PNG_MINUS" ;
GROUP oGrS1 SIZE 28,25; // 60,25 ;
ACTION ( IF( dDataFinale=dDataIniziale,,dDataFinale--),;
oDate2:REFRESH(),EVAL( oDate1:bchange)) BORDER
@ 45,356 ADD BUTTON oBtns[5] ;
BITMAP aBtnfw[1] ; //"BTN_PNG_PLUS" ;
GROUP oGrS1 SIZE 28,25; // 60,25 ;
ACTION ( dDataFinale++,oDate2:REFRESH(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange)) BORDER
@ 5,395 ADD BUTTON oBtns[6] PROMPT "Rinfresca" ;
BITMAP "TOOLBAR_RINFRESCA" ;
GROUP oGrS1 ROUND SIZE 65,65;
ACTION CHANGE_PLAN( dDataIniziale,dDataFinale,lShowNumeri,lshowPagamenti)
oRBar:nLeftMargin = 75
oRBar:CalcPos()
oWnd:Center()
ACTIVATE WINDOW oWnd MAXIMIZED
oRBar:End()
return nil
//------------------------------------------------------------------------------//
// this function refresh the beach or the booking
Function CHANGE_PLAN( dDataIniziale,dDataFinale,lShowNumeri,lshowPagamenti)
Msginfo("procedures")
return nil
//------------------------------------------------------------------------------//
// this function must check the dates get
Function ValidareData( dFechaIni, dFechaFin )
LOCAL lValid := .f.
IF ( dFechaIni <= dFechaFin )
alert( "La data finale deve essere maggiore di quella iniziale " )
lValid := .t.
ENDIF
RETURN lValid
// this function save on dDataIniziale and dDataFinale the values of dStart, dEnd
Function SetDates( dStart, dEnd )
DEFAULT dStart := dDataIniziale
DEFAULT dEnd := dDataFinale
if dStart >= dEnd
return nil
endif
dDataIniziale := dStart
dDataFinale := dEnd
return nil
static Function MenuPopDate(dDataIniziale,dDataFinale,oDate1,oDate2,dBassa1,dBassa4)
Local oPopupDate
MENU oPopupDate POPUP
MENUITEM "Oggi" ACTION ( dDataIniziale :=date(),;
dDataFinale :=date(),;
oDate1:refresh(),oDate2:refresh(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange))
MENUITEM "Domani" ACTION ( dDataIniziale :=date()+1,;
dDataFinale :=date()+1,;
oDate1:refresh(),oDate2:refresh(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange))
MENUITEM "DopoDomani" ACTION (dDataIniziale :=date()+2,;
dDataFinale :=date()+2,;
oDate1:refresh(),oDate2:refresh(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange))
SEPARATOR
MENUITEM "Mese Corrente" ACTION (dDataIniziale:=bom(date()),;
dDataFinale:= eom(date()),;
oDate1:refresh(),oDate2:refresh(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange))
MENUITEM "Mese Prossimo" ACTION (dDataIniziale:=AddMonth(bom(date()),1),;
dDataFinale:= AddMonth(eom(date()),1),;
oDate1:refresh(),oDate2:refresh(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange))
MENUITEM "Stagione" ACTION (dDataIniziale:= (dBassa1),;
dDataFinale:= ( dBassa4) ,;
oDate1:refresh(),oDate2:refresh(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange))
SEPARATOR
MENUITEM "Giugno" ACTION (dDataIniziale:=AddMonth( BOY( DATE() ), 5 ),;
dDataFinale:=EoM(AddMonth( BOY( DATE() ), 5 )),;
oDate1:refresh(),oDate2:refresh(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange))
MENUITEM "Luglio" ACTION (dDataIniziale:=AddMonth( BOY( DATE() ), 6 ),;
dDataFinale:=EoM(AddMonth( BOY( DATE() ), 6 )),;
oDate1:refresh(),oDate2:refresh(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange))
MENUITEM "Agosto" ACTION (dDataIniziale:=AddMonth( BOY( DATE() ), 7 ),;
dDataFinale:=EoM(AddMonth( BOY( DATE() ), 7 )),;
oDate1:refresh(),oDate2:refresh(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange))
MENUITEM "Settembre" ACTION (dDataIniziale:=AddMonth( BOY( DATE() ), 8 ),;
dDataFinale:=EoM(AddMonth( BOY( DATE() ), 8 )),;
oDate1:refresh(),oDate2:refresh(),;
EVAL( oDate1:bchange),;
EVAL( oDate2:bchange))
* SEPARATOR
* MENUITEM "Aggiorna la spiaggia" ACTION CHANGE_PLAN( dDataIniziale,dDataFinale,lShowNumeri,lshowPagamenti)
ENDMENU
return oPopupDate
//----------------------------------------------------------------------//
function GetIni( cIni, cSection, cEntry, xDefault )
local oIni
local xVar := xDefault
// default cIni := oApp():cIniFile
INI oIni FILE cIni
get xVar ;
SECTION cSection ;
ENTRY cEntry ;
default xDefault ;
OF oIni
ENDINI
return xVar
how I can resolve ?