Page 1 of 1

AEvalWhen problems RESOLVED

Posted: Fri Feb 07, 2025 1:36 pm
by Silvio.Falconi
I have two get and two btnbmp

Image

at init the btnbmp must be as you see it on picture
I not wish disabled because then I see a gray button ( bad to see)

I wish activate the btnbmp when the valid when Of the get is valid
each button have a baction


the problem is when I insert a valid mail the btnbmp is not activated ,it is disable

this is the test to try

Code: Select all | Expand


#include "FiveWin.ch"
#include "Constant.ch"

 #define DLG_nColorDlg     RGB(245,245,235)
 #define DLG_nColortitle1  RGB(219,230,244)
 #define DLG_nColortitle2  RGB(207,221,239)
 #define DLG_nColorBar1    RGB(250,250,245)
 #define DLG_nColorBar2    RGB(245,245,235)
 #define DLG_nColorBtn1    RGB(245,245,235)
 #define DLG_nColorBtn2    RGB(250,250,245)
 #define DLG_nColorBtnB    RGB(195,195,185)


Function test()
 local oDlg
 local aGet:=array(2)
  local oSay:=array(2)
 local oBtnSel:= array(2)
 local cCodEmail:=space(30)
 local cCodEmailPec:=space(30)
 local cMailName:=""

 local nRow:=10,nCol:=10
 local nInterlinea:= 30
 local nSizeHGet:= 24

   local nBottom:= 20
   local nRight := 100
   local nHt    := nBottom * DLG_CHARPIX_H
   local nWd    := Max( nRight * DLG_CHARPIX_W, 180 )
   local oCursorBtn :=TCursor():New(,'HAND')

   local  oFont := TFont():New("Tahoma", 0, 18, , )
   local  oBold := TFont():New("Tahoma", 0, 16, , .t.)


DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL ;
       FONT oFont  TiTle "Account Invio" COLOR CLR_BLACK, DLG_nColorDlg  ;
       STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX)

    @ nRow, 320 SAY oSay[1] PROMPT  "email" SIZE 100,25  PIXEL OF oDlg TRANSPARENT  FONT oFont
    @ nRow, 420 GET aGet[1] VAR cCodEmail SIZE 160,nSizeHGet PIXEL OF oDlg;
    ON CHANGE ( oDlg:AEvalWhen(), oDlg:Update() )

   @  nRow, oDlg:nWidth-148  BTNBMP oBtnSel[1] ;
      PROMPT "Account Invio" LEFT                 ;
      RESOURCE "SEL_PIE", "", "SEL_VUO", "" ;
      SIZE 130, nSizeHGet PIXEL FLAT NOROUND GDIP  OF oDlg ;
      WHEN ValidaEmail( cCodEmail )  UPDATE  ;
      ACTION  Account_Invio_Email()

                        /*  ACTION (Account_Invio_Email(), ;
                        IIF(  !empty(cMailName),;
                        oBtnSel[2]:SETFILE("SEL_PIE"),;
                        oBtnSel[2]:SETFILE("SEL_VUO") ) ) ; */

    nRow+=nInterlinea
   @ nRow, 320 SAY oSay[2] PROMPT  "email PEC" SIZE 100,25  PIXEL OF oDlg TRANSPARENT  FONT oFont
   @ nRow, 420 GET aGet[2] VAR cCodEmailPec SIZE 160,nSizeHGet PIXEL OF oDlg;
                     ON CHANGE ( oDlg:AEvalWhen(), oDlg:Update() )



   @  nRow, oDlg:nWidth-148  BTNBMP oBtnSel[2] ;
      PROMPT "Account Invio" LEFT                 ;
      RESOURCE "SEL_PIE", "", "SEL_VUO", "" ;
      SIZE 130, nSizeHGet PIXEL FLAT NOROUND GDIP  OF oDlg ;
      WHEN ValidaEmail( cCodEmailPec )  UPDATE  ;
      ACTION Account_Invio_Email()




            /*  ACTION (Account_Invio_Email(), ;
                        IIF(  !empty(cMailName),;
                        oBtnSel[2]:SETFILE("SEL_PIE"),;
                        oBtnSel[2]:SETFILE("SEL_VUO") ) ) ; */





                For n= 1 to 2
             oBtnSel[n]:bClrGrad := { | lPressed | If( ! lPressed,;
                 { { 1, DLG_nColorBar1, DLG_nColorBar1} },;
                 { { 1, DLG_nColorBar2, DLG_nColorBar2} } ) }
             oBtnSel[n]:nClrBorder := DLG_nColorBtnB
             oBtnSel[n]:oCursor:=   oCursorBtn
             oBtnSel[n]:nClrFocusRect := DLG_nColorBar2
             oBtnSel[n]:nDeepFocusRect := 0
             next

             ACTIVATE DIALOG oDlg CENTERED


RETURN NIL

function validaEmail(cEmail) //Nageswarao
   static preCompiled
   DEFAULT preCompiled := hb_regexComp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$")
      return !Empty( hb_regex( preCompiled, alltrim( cEmail ) ) )

function  Account_Invio_Email ()
            Msginfo("Email")
   return nil
I make now a test
? validaEmail("silvio.falconi@gmail.com")
return .f. so the function of Rao not run ok ?

Re: AEvalWhen problems resolved

Posted: Fri Feb 07, 2025 1:55 pm
by Silvio.Falconi
resolved
it need hbpcre.lib