VALID clause ignore after ESC key

VALID clause ignore after ESC key

Postby dutch » Wed Aug 21, 2013 4:35 am

Dear All,

I've a problem with TGET VALID clause. Because it will now process if the user PRESS ESC key.

How can I force to pass the VALID before leave its input field ? The sample is oGet1, it can input Charactor like "A" and press ESC the Variable will keep "A" without check VALID clause.

Thanks in advance for any help and idea.
Code: Select all  Expand view
// Testing GETs

#include "FiveWin.ch"

function Main()
   LOCAL oDlg, oGet, oGet1
   LOCAL cCad := space(20) // "Testing    " // pad("Testing Gets",40)
   LOCAL nNum := 0
   LOCAL dDat := Date()

   Set century On
   Set Date Ansi
   Set Date format "mm/dd/yyyy"

   SET _3DLOOK ON

   DEFINE DIALOG oDlg TITLE "TGet from " + FWDESCRIPTION

   @ 1,    2 SAY "Text..:" OF oDlg
   @ 1,    6 GET oGet1 VAR cCad OF oDlg SIZE 60, 10 COLOR "W/G" PICTURE "@K" ;
             VALID iif(cCad $ '1234567890',.T.,(MsgStop('wrong input'), .F.))
   @ 1.8,  2 SAY "Number:" OF oDlg
   @ 2,    6 GET oGet VAR nNum OF oDlg SIZE 60, 10 PICTURE "9999999.99"
   @ 2.6,  2 SAY "Date:" OF oDlg
   @ 3,    6 GET oGet VAR dDat PICTURE "@E" OF oDlg SIZE 60, 10  // "@D"
   @ 3,    7 BUTTON "&Ok" OF oDlg SIZE 30, 12 ACTION oDlg:End()
   @ 3,   16 BUTTON "&Cancel" SIZE 30, 12 OF oDlg ACTION oDlg:End() CANCEL
   
   // TGet():SetColorFocus( nRGB( 200, 120, 120 ) )

   ACTIVATE DIALOG oDlg CENTERED

   msginfo( cCad )

return nil
 
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: VALID clause ignore after ESC key

Postby Antonio Linares » Wed Aug 21, 2013 10:49 am

Dutch,

You can do it this way:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()
   LOCAL oDlg, oGet, oGet1
   LOCAL cCad := space(20) // "Testing    " // pad("Testing Gets",40)
   LOCAL nNum := 0
   LOCAL dDat := Date()

   Set century On
   Set Date Ansi
   Set Date format "mm/dd/yyyy"

   SET _3DLOOK ON

   DEFINE DIALOG oDlg TITLE "TGet from " + FWDESCRIPTION

   @ 1,    2 SAY "Text..:" OF oDlg
   @ 1,    6 GET oGet1 VAR cCad OF oDlg SIZE 60, 10 COLOR "W/G" PICTURE "@K" ;
             VALID If( AllTrim( cCad ) $ '1234567890',.T.,(MsgStop('wrong input'), .F.))
   @ 1.8,  2 SAY "Number:" OF oDlg
   @ 2,    6 GET oGet VAR nNum OF oDlg SIZE 60, 10 PICTURE "9999999.99"
   @ 2.6,  2 SAY "Date:" OF oDlg
   @ 3,    6 GET oGet VAR dDat PICTURE "@E" OF oDlg SIZE 60, 10  // "@D"
   @ 3,    7 BUTTON "&Ok" OF oDlg SIZE 30, 12 ACTION oDlg:End()
   @ 3,   16 BUTTON "&Cancel" SIZE 30, 12 OF oDlg ACTION oDlg:End() CANCEL
   
   // TGet():SetColorFocus( nRGB( 200, 120, 120 ) )

   ACTIVATE DIALOG oDlg CENTERED ;
      VALID CheckValids( oDlg )

   msginfo( cCad )

return nil
 
function CheckValids( oDlg )

   local nAt := AScan( oDlg:aControls, { | oCtrl | oCtrl:hWnd == GetFocus() } )
   local oCtrl
   
   if nAt != 0
      oCtrl = oDlg:aControls[ nAt ]
      If oCtrl:IsKindOf( "TGET" ) .and. oCtrl:bValid != nil
         return Eval( oCtrl:bValid )
      endif
   endif
   
return .T.          
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: VALID clause ignore after ESC key

Postby dutch » Thu Aug 22, 2013 1:07 am

Dear Antonio,

Thanks for your great support, it is working as expectation.

Wonderful....

Regards,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests