FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour VALID clause ignore after ESC key
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
VALID clause ignore after ESC key
Posted: Wed Aug 21, 2013 04: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 (fw): Select all Collapse
// 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 2304 / 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)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: VALID clause ignore after ESC key
Posted: Wed Aug 21, 2013 10:49 AM
Dutch,

You can do it this way:

Code (fw): Select all Collapse
#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
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: VALID clause ignore after ESC key
Posted: Thu Aug 22, 2013 01:07 AM

Dear Antonio,

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

Wonderful....

Regards,
Dutch

Regards,

Dutch



FWH 2304 / 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)

Continue the discussion