Problem with datepick

Problem with datepick

Postby Silvio.Falconi » Fri Mar 06, 2020 8:00 am

I have these controls
Image

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

Image

the datepick not execute the valid function and for a sample then I have the error

Image


the datepick execute before and only the change command




Image

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  Expand view  RUN



    #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 ?
Last edited by Silvio.Falconi on Tue Mar 10, 2020 10:07 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with datepick

Postby Silvio.Falconi » Tue Mar 10, 2020 9:30 am

Please Any solution ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with datepick

Postby nageswaragunupudi » Wed Mar 11, 2020 10:00 am

Code: Select all  Expand view  RUN
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


The standard behavior of all controls is that VALID function is executed only when the control loses focus. If we want some checks to be made before the control loses focus, we need to use ON CHANGE functionality ( or bChanged )

This is how all controls behave and datepicker is no exception.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problem with datepick

Postby Silvio.Falconi » Wed Mar 11, 2020 11:01 am

Sorry Nages,
I not uderstood
On Datepick control I use the ON CHANGE ....

even if I delete valid when I press the "+" and "-" not refresh the date of the control datepick but execute that bchange function

the function valid need to check if datestart is <= of dataend
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with datepick

Postby karinha » Wed Mar 11, 2020 12:56 pm

Master Nages, I didn't understand what you wrote. Is there an example using DTPICKER, which uses ON CHANGE? What class controls DTPICKER, or is it internal to the Fivewin LIB? Thank you very much and have a great day. Your examples are wonderful, I learn a lot from you. Greetings.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Problem with datepick

Postby nageswaragunupudi » Wed Mar 11, 2020 1:46 pm

karinha wrote:Master Nages, I didn't understand what you wrote. Is there an example using DTPICKER, which uses ON CHANGE? What class controls DTPICKER, or is it internal to the Fivewin LIB? Thank you very much and have a great day. Your examples are wonderful, I learn a lot from you. Greetings.

Regards, saludos.


FWH provides TDatePick and TTimePick classes based on Windows "SysDateTimePick32" control (commands in dtpicker.ch) and TCalendar class based on Windows sister control "SysMonthCal32" (calendar.ch). Please look for samples in the samples folder and in the forums.

In addition, FWH provides its own functionx XBrGetDate() and MsgDate() which provide functionality similar to TDatePick control.

In version FWH2003, there will be many improvements to the TDatePick control including limiting range of dates for selection, multi-selection feature (selection of a range of dates by mouse-drag or shift-click), etc.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problem with datepick

Postby karinha » Wed Mar 11, 2020 1:56 pm

Silvio, so that we can understand where the error is, use this code modified by me, and tell me where the error is. Use the google translator and write in english, spanish and if possible in portuguese, i can't understand what is wrong, because the translation from your english does not return me correct.

// FWH..\SAMPLES\SILVIO2.PRG

Code: Select all  Expand view  RUN

#include "fivewin.ch"
#include "constant.ch"
#include "ribbon.ch"
#include "dtpicker.ch"

//are data  of Tapplication
STATIC dDataIniziale, dDataFinale, lShowNumeri, lshowPagamenti
STATIC oWnd

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 ) )

   ENDMENU

RETURN oPopupDate
//----------------------------------------------------------------------//
FUNCTION GetIni( cIni, cSection, cEntry, xDefault )

   LOCAL oIni
   LOCAL xVar := xDefault

   INI oIni FILE cIni

   GET xVar            ;
      SECTION cSection ;
      ENTRY cEntry     ;
      DEFAULT xDefault ;
      OF oIni
   ENDINI

RETURN xVar
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Problem with datepick

Postby albeiroval » Wed Mar 11, 2020 4:49 pm

Mr Rao.

In version FWH2003, there will be many improvements to the TDatePick control including limiting range of dates for selection, multi-selection feature (selection of a range of dates by mouse-drag or shift-click), etc.


Very interesting. If possible you should also add change title, background color and text color in the dtpicker
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 383
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: Problem with datepick

Postby nageswaragunupudi » Wed Mar 11, 2020 6:00 pm

Code: Select all  Expand view  RUN
Very interesting. If possible you should also add change title, background color and text color in the dtpicker
 

SysDatePicker32 class of Windows, in fact, provides for setting/changing font and all the colors you mentioned.
But the sad part is that these do not work at all in Themed Applications. (Yes, they work in non-themed applications).
Because most of our applications these days are themed, we are not providing these features.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problem with datepick

Postby Silvio.Falconi » Wed Mar 11, 2020 6:02 pm

Please Use this final test.prg

Code: Select all  Expand view  RUN

    #include "fivewin.ch"
    #include "constant.ch"
    #include "ribbon.ch"
    #include "dtpicker.ch"

    //are data  of Tapplication
    STATIC dDataIniziale, dDataFinale, lShowNumeri, lshowPagamenti
    STATIC oWnd

    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   ( dDataStart--, oDate1:REFRESH(), ;
          EVAL( oDate1:bchange ) ) BORDER

       @ 45, 188   ADD BUTTON oBtns[3] ;
          BITMAP  aBtnfw[1] ;
          GROUP oGrS1  SIZE 28, 25; // 60,25    ;
          ACTION   ( IF( dDataStart < dDataEnd,dDataStart++,(dDataStart++,dDataEnd++ ) ), ;
          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( dDataEnd = dDataStart,,dDataEnd-- ), ;
          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   ( dDataEnd++, 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( dDataStart, dDataEnd, 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 ) )

       ENDMENU

    RETURN oPopupDate
    //----------------------------------------------------------------------//
    FUNCTION GetIni( cIni, cSection, cEntry, xDefault )

       LOCAL oIni
       LOCAL xVar := xDefault

       INI oIni FILE cIni

       GET xVar            ;
          SECTION cSection ;
          ENTRY cEntry     ;
          DEFAULT xDefault ;
          OF oIni
       ENDINI

    RETURN xVar
   



I fill out the test with harbour
make sure to set the date command well I use the Italian format
As soon as you load the test you will see a ribbonbar, a button on the left,
two datepick controls with each two small buttons "-" and "+" and then another button on the right

Image

To make you understand what the problems are, you need to do these things
I tried the test with Windows Seven and Windows 10 Pro

keep in mind that when the procedure displays the message "Procedures"
t means that it refreshes the booking page or the beach, here for convenience and space I have not put the code


1) if I press the green button "+" the one on the right oBtns [5]
2) the procedure displays a msginfo ("Procedures") refresh the control (oDate2)
3) if I press the red button "-" the one on the right oBtns [4]
and the oDate2 control cools down by going back if oDate2 is equal to oDate1 after it does not go back,
that is, it does not put a date lower than oDate1 but rightly so

initially works well ie if you have

oDate1 March 11, 2020
odate2 March 11, 2020


that is, the date of the day you try the test

pressing the button "-" the one on the right oBtns [4] the procedure decreases the date until it equals oDate1 and does not go beyond

below I will explain what does not work remember this point XX

3) if I press the green button "+" oBtns [3] the one under oDate1 increases the date as it should be so and here is the first error because it refreshes twice in fact you will see the message msginfo twice (" Procedures ") this is wrong it should only be done once

4) if I press the red button "-" the one on the left works well the date oDate1 decreases

5) Now I press the datepick control button oDate1 and select the date in the calendar, the control refreshes but you will see the message msginfo ("Procedures") twice, the same operation you have to do for the other control oDate2 and you will see the message msginfo twice ("Procedures")

the error is that it should display msginfo ("Procedures") once

Errors

Let's say that the end user goes with the mouse to modify the date inside the control, it highlights what you need to modify,

if you press all the buttons are blocked, if you press the button the one on the left in the ribbonbar does not run the menu popup,

Image

you can only press the ";" buttons on your keyboard or ":" to scroll inside the control, if you press "esc" nothing happens,

practically you are blocked and you do not exit the control.




you can only press the calendar button and you can change the date
for example put a date bigger than odate2, the procedure makes you change the date for example I entered

oDate1 March 15, 2020
oDate2 I still have 11 March 2020


you see it ?
already does not check if the start date is less than the end date


Do you remember the XX point described above? ok

you have to press the red button "-" the one on the right oBtns [4]

Before the procedure came to be equal to oDate1 and then it stopped, that is,
it did not decrease the date,

now with the wrong date because in fact we put in oDate1 a date greater than oDate2 the procedure goes in error
not even showing the error message of the valid function "The end date must be greater than the start date"

Error on Menupopup
Now let's analyze the first button that of the popup menu there are submenus

Today
tomorrow
day after tomorrow
Current month
Next month
season
June
July
August
September


if I select "Today" - I see the message Msginfo (procedures ") twice ERROR

if I select "tomorrow" - I see the message Msginfo (procedures ") twice ERROR

if I select "the day after tomorrow" - I see the message Msginfo (procedures ") twice ERROR

if I select "Current month" I see once the message Msginfo (procedures ")
if I select "Next month" I see the message Msginfo (procedures ") once
if I select "season" I see once the message Msginfo (procedures ")
if I select "june" I see once the message Msginfo (procedures ")
if I select "july" I see once the message Msginfo (procedures ")
if I select "august" I once see the message Msginfo (procedures ")
if I select "september" I see once the message Msginfo (procedures ")


I hope you help me solve these problems
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with datepick

Postby Silvio.Falconi » Thu Mar 12, 2020 9:11 am

translate por Joao (google translate)

Compilar o teste com harbour
recursos de imposição de dados de comando

Uso do formato italiano
Não é possível testar o teste, inclua uma barra multifuncional, pressione o botão direito do mouse e faça o controle de data e hora com o botão de controle de piccoli pulsanti "-" e "+"

Image


Para os capitães que são problemas, devi fare quese cose:

Como testar o Windows Seven e Windows 10 Pro

Devi apresentar aqui quando o procedimento visualiza a mensagem "Procedure"
significa que você aceita a paginação de pré-visualização ou a spiaggia, que permite acomodação e espaço não inseridos no código


se premo o pulsante verde "+" quello to destro oBtns [5]
o procedimento visualizado em um msginfo ("Procedures") atualiza o controle (oDate2)

se premo il pulsante rosso "-" quello a destra oBtns [4]
e o controle oDate2 e o código de acesso indeterminado se o Data2 for normal ou o data1, caso não se torne indiferente,
aqui, não use dados inferidos a oDate1, se estiver ok

inizialmente funziona bene, cioè se hai

oData1 12 março 2020
odate2 12 março 2020

dados, dados do dia no teste provi

premindo o pulsante "-" quello to destro oBtns [4] o procedimento diminui os dados até quando não é normal no oDate1 e não tem mais (non va indietro)

de seguidos spiegherò cosa non funziona, ricordo this point (XX)

se você premir o pulsante verde "+" oBtns [3], a data de nascimento1 aumenta os dados que são extraídos aqui e é o primeiro erro que ocorre porque você deve atualizar antes de enviar mensagens de mensagem devido a repetir ("Procedimentos") é inválido. solo una volta

preveja o pulsante rosso "-" quello a sinistra funziona bene the data oDate1 diminuir

Agora, selecione o pulsador de controle datepick oDate1 e selecione os dados no calendário,
o controle e a atualização podem conter a mensagem msginfo ("Procedures") devido a devolução,
a operação de destino que fornece tarifa para o outro controlador de data / hora2 e agora é devido devido à mensagem de mensagem ("Procedure")

Se você tiver problemas de visualização visual ("Procedimento") em uma volta e não vencida, quase sempre adiantará a reserva devida novamente

Errori

Suponha que o último final de senha com o mouse modifique os dados todos dentro do controle, evidência que você deve modificar o que é necessário para modificar o modo de exibição ecc

como cursore dentro do controle datepick

se estiver tudo pronto para pulsar, se estiver pronto para ouvir uma sinistra na barra de multifunções, não selecione o menu pop-up,


Image

puoi solo premere il tasto ";" pulsanti sulla tastiera o ":" for scorrere all'interno del controllero,

se si preme "esc" non accade nulla,

praticamente sei bloco e controle não secundário.

você simplesmente premia o pulsador do calendário, o quelo do controle datepick e alterna os dados
como inserir um dado maior do que o odate2, o procedimento para alterar os dados é como inserir

oData1 15 março 2020
oDate2 Até 12 de março de 2020

lo vedi?
como não controlar os dados de inferência é inferir todos os dados de fine

existe um ma non la esegue válido

Você está registrado (XX) como descrito? Está bem

devi premere the pulsante rosso "-" quello a destra oBtns [4]

Prima se premevi "-" o controlador de data e hora e o indicador de dados até um período não anterior a data1 e data e hora,

Agora, com os dados do banco de dados perdidos em efeitos relacionados a inserção no Data1, um dado maior do DataD2, o procedimento va em erro

la non non funziona perchè dovrebbe visualizzare
"Os dados finos devem ser adicionados aos dados de inicialização"

Errore su Menupopup
Agora, analise o primeiro pulsante no menu pop-up

Oggi
Domani
dopodomani
Corrente mese
Il prossimo mese
estagione
Giugno
luglio
agosto
settembre


selecione "Oggi" - veja a mensagem Msginfo (procedure ") devido a ERRORE

selecione "domani" - veja a mensagem Msginfo (procedure ") devido a ERRORE

selecione "dopodomani" - veja a mensagem Msginfo (procedure ") devido a ERRORE

selecione "Mese corrente" para retornar uma mensagem Msginfo (procedure ")
selecione "O meu próximo passo" para ver a mensagem Msginfo (procedure ") em uma volta
selecione "etapa" para retornar uma mensagem Msginfo (procedure ")
selecione "giugno" para exibir uma mensagem Msginfo (procedure ")
selecione "luglio" para retornar uma mensagem Msginfo (procedure ")
selecione "agosto" para retornar uma mensagem Msginfo (procedure ")
selecione "setembre" para retornar uma mensagem Msginfo (procedure ")


Spero che mi aiuti a risolvere questi problemi
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with datepick

Postby Silvio.Falconi » Thu Mar 12, 2020 10:17 am

nageswaragunupudi wrote:
Code: Select all  Expand view  RUN
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


The standard behavior of all controls is that VALID function is executed only when the control loses focus. If we want some checks to be made before the control loses focus, we need to use ON CHANGE functionality ( or bChanged )

This is how all controls behave and datepicker is no exception.


Nages,
to simplify I created a minimal test.


Code: Select all  Expand view  RUN



#include "fivewin.ch"
#include "dtpicker.ch"

static dDataIniziale,  dDataFinale ,lShowNumeri, lshowPagamenti

Function test()
local oDlg
local oDate1,oDate2
local dDatastart := date()
local dDataEnd := date()
local oFont
LOCAL oBtn

SET DATE TO ITALIAN

dDataIniziale := date()
dDataFinale   := date()


   DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 8
   DEFINE DIALOG oDlg FROM 100, 100 TO 230,376;
                 TITLE "TEST DATEPICK" PIXEL FONT oFont


   @ 12, 10 SAY "Date1:" OF oDlg SIZE 21, 8 PIXEL FONT oFont
   @ 10, 36 DTPICKER  oDate1 VAR dDatastart OF oDlg SIZE 100, 12 PIXEL FONT oFont ;
             UPDATE PICTURE "ddd dd mmm yyyy"  ;
              ON CHANGE ( if( dDatastart != dDataIniziale,;
          ( SetDates( dDatastart ), ;
          CHANGE_PLAN( dDatastart, dDataEnd, lShowNumeri, lshowPagamenti ) ), ) ) ;
          VALID ValidareData( dDatastart, dDataEnd )


   @ 26, 10 SAY "Date2:" OF oDlg SIZE 21, 8 PIXEL FONT oFont
   @ 24, 36  DTPICKER  oDate2 VAR dDataEnd OF oDlg SIZE 100, 12 PIXEL FONT oFont ;
            UPDATE PICTURE "ddd dd mmm yyyy"  ;
             ON CHANGE ( if( dDataEnd != dDataFinale,;
          ( SetDates( ,dDataEnd ), ;
          CHANGE_PLAN( dDatastart, dDataEnd, lShowNumeri, lshowPagamenti ) ), ) ) ;
          VALID ValidareData( dDatastart, dDataEnd )


   @ 46, 48 BUTTON oBtn PROMPT "Conferma" OF oDlg SIZE 42, 14 PIXEL FONT oFont DEFAULT ACTION (oDlg:End(), lSave := .T.)
   @ 46, 92 BUTTON oBtn PROMPT "Annulla" OF oDlg SIZE 42, 14 PIXEL FONT oFont CANCEL ACTION (oDlg:End())


activate dialog odlg
return nil
//------------------------------------------------------------------//
 FUNCTION ValidareData( dFechaIni, dFechaFin )

       LOCAL lValid := .t.

       IF ( dFechaIni >  dFechaFin )
          alert( "The end date must be greater than the start date " )
          lValid := .f.
       ENDIF

       RETURN lValid
//------------------------------------------------------------------//
Function CHANGE_PLAN( dDatastart, dDataEnd, lShowNumeri, lshowPagamenti )
   Msginfo("refreshing....")
   return nil
//------------------------------------------------------------------------------


   // from TPlanning Class ( sample.prg)
  FUNCTION SetDates( dStart, dEnd )

       DEFAULT dStart := dDataIniziale
       DEFAULT dEnd   := dDataFinale

       IF dStart >= dEnd
          RETURN nil
       ENDIF

       dDataIniziale := dStart
       dDataFinale   :=  dEnd

    RETURN ni


 



if you change the date at the first datepick and select a date bigger than the second datepick, it does not perform the Valid

but performs the refresh function (on change) twice
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with datepick

Postby karinha » Thu Mar 12, 2020 1:22 pm

// \SAMPLES\SILVIO3.PRG - \XHB74\BIN\HBFORMAT SILVIO3.PRG

// Silvio, Continue...

Code: Select all  Expand view  RUN

#include "fivewin.ch"
#include "dtpicker.ch"

STATIC dDataIniziale, dDataFinale, lShowNumeri, lshowPagamenti
STATIC lSave := .F.

FUNCTION SILVIO3()  // In Test - en teste - em teste.

   LOCAL oDlg, oDate1, oDate2, oFont, oBtn
   LOCAL dDatastart := Date()
   LOCAL dDataEnd   := Date()

   SET DATE TO ITALIAN

   dDataIniziale := Date()
   dDataFinale   := Date()

   DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 8

   DEFINE DIALOG oDlg FROM 100, 100 TO 230, 376 TITLE "TEST DATEPICK" PIXEL ;
          FONT oFont COLORS CLR_BLACK, CLR_WHITE TRANSPARENT

   oDlg:lHelpIcon := .F.

   @ 12, 10 SAY "Date1:" OF oDlg SIZE 21, 8 PIXEL FONT oFont

   @ 10, 36 DTPICKER  oDate1 VAR dDatastart OF oDlg SIZE 100, 12 PIXEL ;
      FONT oFont UPDATE PICTURE "ddd dd mmm yyyy"  ;
      ON CHANGE ( IF( dDatastart != dDataIniziale, ;
                    ( SetDates( dDatastart ),      ;
      CHANGE_PLAN( dDatastart, dDataEnd, lShowNumeri, lshowPagamenti ) ), ) ) ;
      VALID ValidareData( dDatastart, dDataEnd )

   @ 26, 10 SAY "Date2:" OF oDlg SIZE 21, 8 PIXEL FONT oFont

   @ 24, 36  DTPICKER  oDate2 VAR dDataEnd OF oDlg SIZE 100, 12 PIXEL ;
      FONT oFont UPDATE PICTURE "ddd dd mmm yyyy"  ;
      ON CHANGE ( IF( dDataEnd != dDataFinale,     ;
                    ( SetDates( ,dDataEnd ),       ;
      CHANGE_PLAN( dDatastart, dDataEnd, lShowNumeri, lshowPagamenti ) ), ) ) ;
      VALID ValidareData( dDatastart, dDataEnd )

   @ 46, 48 BUTTON oBtn PROMPT "Conferma" OF oDlg SIZE 42, 14 PIXEL FONT oFont ;
      ACTION ( oDlg:End(), lSave := .T. ) DEFAULT

   @ 46, 92 BUTTON oBtn PROMPT "Annulla" OF oDlg SIZE 42, 14 PIXEL FONT oFont ;
      ACTION ( oDlg:End() ) CANCEL

   ACTIVATE DIALOG oDlg

   oFont:End()

RETURN NIL

FUNCTION ValidareData( dFechaIni, dFechaFin )

   IF ( dFechaIni > dFechaFin )

      Alert( "The end date must be greater than the start date " )

      RETURN( .F. )

   ENDIF

RETURN( .T. )

FUNCTION CHANGE_PLAN( dDatastart, dDataEnd, lShowNumeri, lshowPagamenti )

   Msginfo( "refreshing, Cual Objeto?" )

RETURN NIL

// from TPlanning Class ( sample.prg)

FUNCTION SetDates( dStart, dEnd )

   DEFAULT dStart := dDataIniziale
   DEFAULT dEnd   := dDataFinale

   IF dStart >= dEnd

      RETURN NIL

   ENDIF

   dDataIniziale := dStart
   dDataFinale   := dEnd

RETURN NIL
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Problem with datepick

Postby Silvio.Falconi » Sun Mar 15, 2020 5:19 pm

sometimes run ok and sometimes run bad
sometimes When the user have a cursor on control the other buttons not run ok and lose the valid function
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 82 guests