get problem not execute ON CHANGE command

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

get problem not execute ON CHANGE command

Post by Silvio.Falconi »

I did not understand why if I have a get control to which I change the value, it does not execute the "On change" command
to execute this command I have to add EVAL (aGet [1]: bchange)

sample :

DEFINE DIALOG oDlg SIZE 400,200 Title "test date,valid"


@ 12,5 SAY "Dal :" OF oDlg PIXEL SIZE 100,20 TRANSPARENT

@ 10,35 GET aGet[1] VAR dDataIniziale SIZE 100,12 PIXEL OF oDlg ;
BITMAP ".\bitmaps\cal.bmp" ;
ACTION (dDataIniziale:= XbrGetDate(txt_to_date( dDataIniziale) , "Select a date",dStagioneMin,dStagioneMax, .t., 0.6, ,aGet[1] ),;
IIF( dDataIniziale=ctod("") .or. dDataIniziale=nil ,;
(dDataIniziale:="Select a date",aGet[1]:CTEXT(date_to_txt(dDataIniziale))),;
aGet[1]:CTEXT(date_to_txt(dDataIniziale)) ) ,;
aGet[1]:refresh(),EVAL( aGet[1]:bchange)) ;
VALID ValidareData(txt_to_date(dDataIniziale),txt_to_date( dDataFinale) ) ;
ON CHANGE ( dtemp1:= txt_to_date( dDataIniziale),;
dtemp2:= txt_to_date( dDataFinale) ,;
dDataIniApp:=dtemp1,;
dDataFinApp:=dtemp2,;
CHANGE_PLAN( dDataIniApp,dDataFinApp,lShowNumeri,lshowPagamenti) )


If I not insert EVAL( aGet[1]:bchange) the get not execute the command ON CHANGE why ?


Image



the test

Code: Select all

#include "FiveWin.ch"
#include "constant.ch"
//----------------------------------------------------------------------------//
REQUEST HB_Lang_IT
REQUEST HB_CODEPAGE_ITWIN


function Main()

   local oDlg , aGet := Array(5), oBtnCal
   local dDataIniziale,dDataFinale  // date of the get
   local dStagioneMin     // date limit
   local dStagioneMax     // date limit
   local dtemp1,dtemp2

local dDataIniApp
local dDataFinApp
local lShowNumeri,lshowPagamenti


  SET _3DLOOK ON
  SET CENTURY ON
  SET DATE ITALIAN

    HB_LangSelect("IT")
    HB_SetCodePage("ITWIN")

     dDataIniApp := date()     // date format  // date of application
     dDataFinApp := date()

     dDataIniziale:= date_to_txt(date())   // string format
     dDataFinale := date_to_txt(date())

     dStagioneMin := ctod("17/05/2020")       // date format
     dStagioneMax := ctod("20/09/2020")

     lShowNumeri     := .t.
     lshowPagamenti  := .t.


     DEFINE DIALOG oDlg  SIZE 400,200 Title "test date,valid"


      @ 12,5 SAY "Dal :" OF  oDlg PIXEL SIZE 100,20 TRANSPARENT
      @ 10,35 GET aGet[1] VAR dDataIniziale SIZE 100,12 PIXEL OF oDlg ;
      BITMAP  ".\bitmaps\cal.bmp" ;
      ACTION (dDataIniziale:= XbrGetDate(txt_to_date( dDataIniziale) ,;
                            "Select a date",dStagioneMin,dStagioneMax, .t., 0.6, ,aGet[1] ),;
                IIF( dDataIniziale=ctod("") .or. dDataIniziale=nil ,;
                                         (dDataIniziale:="Select a date",aGet[1]:CTEXT(date_to_txt(dDataIniziale))),;
                                         aGet[1]:CTEXT(date_to_txt(dDataIniziale)) ) ,;
                                         aGet[1]:refresh(),EVAL( aGet[1]:bchange)) ;
                 VALID ValidareData(txt_to_date(dDataIniziale),txt_to_date( dDataFinale) )  ;
       ON CHANGE (  dtemp1:= txt_to_date( dDataIniziale),;
                    dtemp2:= txt_to_date( dDataFinale)  ,;
                     dDataIniApp:=dtemp1,;
                     dDataFinApp:=dtemp2,;
                    CHANGE_PLAN( dDataIniApp,dDataFinApp,lShowNumeri,lshowPagamenti) )

      aGet[1]:lAdjustBtn:=.t.




             //aGet[1]:oBtn:oCursor:= TCursor():New(,'HAND')

      @ 26,5 SAY "al :" OF  oDlg PIXEL SIZE 100,20 TRANSPARENT
      @ 24,35 GET aGet[2] VAR dDataFinale SIZE 100,12 PIXEL OF oDlg ;
      BITMAP  ".\bitmaps\cal.bmp" ;
      ACTION (dDataFinale:= XbrGetDate(txt_to_date( dDataFinale) ,;
                            "Select a date",dStagioneMin,dStagioneMax, .t., 0.6, ,aGet[2] ),;
              IIF( dDataFinale=ctod("") .or. dDataFinale=nil ,;
                                         (dDataFinale:="Select a date",aGet[2]:CTEXT(date_to_txt(dDataFinale))),;
                                         aGet[2]:CTEXT(date_to_txt(dDataFinale)) ) ,;
                                         aGet[2]:refresh(),EVAL( aGet[2]:bchange)) ;
       VALID ValidareData(txt_to_date(dDataIniziale),txt_to_date( dDataFinale) )  ;
       ON CHANGE (  dtemp1:= txt_to_date( dDataIniziale),;
                    dtemp2:= txt_to_date( dDataFinale)  ,;
                     dDataIniApp:=dtemp1,;
                     dDataFinApp:=dtemp2,;
                    CHANGE_PLAN( dDataIniApp,dDataFinApp,lShowNumeri,lshowPagamenti) )



     aGet[2]:lAdjustBtn:=.t.



  @ 07,170  BTNBMP oBtnCal FILENAME ".\bitmaps\cal.bmp" FLAT SIZE 20,14 PIXEL OF oDlg NOBORDER
      oBtnCal:oPopUp:= { |oBtn| BtnPopCalMenu( @dDataIniziale,@dDataFinale,aGet) }


   @ 40,10 button "test" size 40,12 pixel  of oDlg  action  CHANGE_PLAN(dDataIniApp, dDataFinApp,lShowNumeri,lshowPagamenti)

   ACTIVATE DIALOG oDlg CENTERED

   return nil


//------------------------------------------------------------------------------------//
  Function CHANGE_PLAN(  dDateStart, dDateEnd,lShowNumeri,lshowPagamenti)
      msginfo(   date_to_txt(dDateStart)+CRLF+date_to_txt(dDateEnd)," Check " )
   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 BtnPopCalMenu( dDataIniziale,dDataFinale,aGet)
  Local oPopupDate

     MENU oPopupDate POPUP 2015
     MENUITEM "Oggi";
          ACTION  (dDataIniziale:=date(), dDataFinale:=date(), ;
                               aGet[1]:CTEXT(date_to_txt(dDataIniziale)), ;
                               aGet[1]:refresh()                          ,;
                               aGet[2]:CTEXT(date_to_txt(dDataFinale)),   ;
                               aGet[2]:refresh() )
      MENUITEM "Domani" ;
           ACTION  (dDataIniziale:=date()+1,dDataFinale:=date()+1, ;
                               aGet[1]:CTEXT(date_to_txt(dDataIniziale)),;
                               aGet[1]:refresh()                         ,;
                               aGet[2]:CTEXT(date_to_txt(dDataFinale)),  ;
                               aGet[2]:refresh() )
      MENUITEM "DopoDomani";
           ACTION (dDataIniziale:=date()+2,dDataFinale:=date()+2, ;
                               aGet[1]:CTEXT(date_to_txt(dDataIniziale)),;
                               aGet[1]:refresh()                       ,;
                               aGet[2]:CTEXT(date_to_txt(dDataFinale)),  ;
                               aGet[2]:refresh() )
      SEPARATOR
      MENUITEM "Pulisci";
           ACTION ( dDataIniziale:="select a date", dDataFinale:="select a date",;
                                 aGet[1]:CTEXT(dDataIniziale), ;
                                 aGet[1]:refresh()                       ,;
                                 aGet[2]:CTEXT(dDataFinale), ;
                                 aGet[2]:refresh() )

      ENDMENU

   return oPopupDate
 //--------------------------------------------------------------------------------------------------------------//
   Function date_to_txt(dDate)
      return FW_TRANSFORM( dDate, "ddd, dd mmm yyyy" )
//--------------------------------------------------------------------------------------------------------------//
Function txt_to_date(cDate)
      return uCharToVal(cDate, "D" )

//--------------------------------------------------------------------------------------------------------------//

 
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: get problem not execute ON CHANGE command

Post by karinha »

Try:

ON CHANGE( My_Function(... ) )
João Santos - São Paulo - Brasil
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: get problem not execute ON CHANGE command

Post by Silvio.Falconi »

karinha,

allready tried
static dDataIniApp,dDataFinApp,lShowNumeri,lshowPagamenti //because are DATA variables


ON CHANGE ( MyFunction(dDataIniziale,dDataFinale) )

Function MyFunction(dDataIniziale,dDataFinale)
local dtemp1:= txt_to_date( dDataIniziale)
local dtemp2:= txt_to_date( dDataFinale)

dDataIniApp:=dtemp1
dDataFinApp:=dtemp2

CHANGE_PLAN( dDataIniApp,dDataFinApp,lShowNumeri,lshowPagamenti)

return nil


it need only EVAL( aGet[2]:bchange) otherwise it does not bchange


I tried also with

aGet[1]:bchange := { || MyFunction(dDataIniziale,dDataFinale) }
aGet[2]:bchange := { || MyFunction(dDataIniziale,dDataFinale) }

not run
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: get problem not execute ON CHANGE command

Post by karinha »

Don't you have to refresh() the object?
João Santos - São Paulo - Brasil
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: get problem not execute ON CHANGE command

Post by Silvio.Falconi »

the problem is not refresh the get but assign the new values on dDataIniApp and dDataFinApp are two data of Tapplication()
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Marcelo Roggeri
Posts: 275
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina
Contact:

Re: get problem not execute ON CHANGE command

Post by Marcelo Roggeri »

Hola buenos dias,
Sigue habiendo problemas con el ON CHANGE del Método TGET, como se puede solucionar?

Ejemplo:

Code: Select all

REDEFINE GET oGet1 VAR mGET1 ID 11     OF oDlg ON CHANGE (mGET2:=mGET1+10,oGet2:Refresh())
REDEFINE GET oGet2 VAR mGET2 ID 12     OF oDlg   
 
No se actualiza el valor del segundo get (oGet2)

Muchas gracias...
FWH - Harbour - BCC7 - PellesC - FivEdit (Cristobal Navarro)
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: get problem not execute ON CHANGE command

Post by karinha »

// \SAMPLES\TESTGET7.PRG

Code: Select all

#include "fivewin.ch"

function main()

   FromRes()
 
return nil
   
Function FromRes()

   local oDlg
   local oGet1, oGet2, oGet3, oGet4
   local cVar1, cVar2, cVar3, cVar4
   local lActive := .f.
   
   cVar1 := 0
   cVar2 := 0
   cVar3 := 0
   cVar4 := 0
   
   define dialog oDlg resource "fromres"

   redefine get oGet1 var cVar1 id 100 bitmap "on" ;
      action( msginfo( "With Transparent" ) ) of oDlg

   redefine get oGet2 var cVar2 id 101 bitmap "on" ;
      action( msginfo( "Without Transparent" ) )   ;
      ON CHANGE SUMA_GETS( oGet1, oGet2, oGet3, cVar1, cVar2 ) of oDlg

   redefine get oGet3 var cVar3 id 102 bitmap "chkyes" ;
      action( msginfo( "With Adjust-Transparent" ) );
      COLOR CLR_BLACK, CLR_CYAN of oDlg

   redefine get oGet4 var cVar4 id 103 bitmap "chkyes" ;
   action( if( lActive,oGet3:disable(), oGet3:enable()), lActive:= !lActive, ;
      oDlg:update() ) of oDlg
   
   oGet1:lBtnTransparent := .t.       // transparent button get oGet1
   
   oGet3:disable()
   oGet3:lBtnTransparent := .t.       // transparent button get oGet3
   oGet3:lAdjustBtn      := .t.       // Button Get Adjust Witdh oGet3
   oGet3:lDisColors      := .f.       // Deactive disable color
   oGet3:nClrTextDis     := CLR_WHITE // Color text disable status
   oGet3:nClrPaneDis     := CLR_BLUE  // Color Pane disable status

   oGet4:lAdjustBtn := .t.
   
   activate dialog oDlg centered
 
return nil

function SUMA_GETS( oGet1, oGet2, oGet3, cnVar1, cnVar2 )

   local nVal1  := 0
   local nVal2  := 0
   local nValor := 0

   nVal1 := cnVar1
   nVal2 := cnVar2

   nValor := nVal2 + nVal1 + 10

   oGet3:VARPUT( nValor )
   oGet3:Refresh()

RETURN( .T. )
 
// TESTGET7.RC

Code: Select all

// RESOURCE SCRIPT generated by "Pelles C for Windows, version 5.00".
#ifndef __64__
  1 24 "winxp\WindowsXP.Manifest" 
#endif

#ifdef __64__
  1 24 "winxp\WindowsXP.Manifest64"
#endif 


FROMRES DIALOG 0, 0, 150, 150
STYLE DS_MODALFRAME | WS_BORDER | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
FONT 8, "MS Sans Serif"
CAPTION "Dialog"
BEGIN
    EDITTEXT        100, 11, 10, 80, 15, ES_AUTOHSCROLL
    EDITTEXT        101, 10, 40, 80, 15, ES_AUTOHSCROLL
    EDITTEXT        102, 9, 70, 129, 17, ES_AUTOHSCROLL
    EDITTEXT        103, 10, 100, 130, 14, ES_AUTOHSCROLL
END

ON BITMAP "..\bitmaps\on.bmp"

CHKYES BITMAP "..\bitmaps\chkyes.bmp"
 
João Santos - São Paulo - Brasil
User avatar
Marcelo Roggeri
Posts: 275
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina
Contact:

Re: get problem not execute ON CHANGE command

Post by Marcelo Roggeri »

Muchas gracias Karinha voy a probar ese ejemplo
Saludos
FWH - Harbour - BCC7 - PellesC - FivEdit (Cristobal Navarro)
Post Reply