FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Cancel on Valid
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Cancel on Valid
Posted: Thu Dec 08, 2011 04:22 PM
To All

I am trying to trap my Cancel button event during a Get - Valid scenario .. Here is the code

Code (fw): Select all Collapse
Static lClose := nil
..
REDEFINE GET oClname        VAR cClname        ID 120 of oREQ PICTURE "@!" ;
            valid CustGet(cClname, cMODE, oRsReq, oButt1,oButt2,oButt3,oButt4, "1") UPDATE

...
...
...

REDEFINE BTNBMP oBUTT2 ID 112 of oREQ   ;    // cancel
         RESOURCE "CANCEL1","DCANCEL1","DCANCEL1" ;
         PROMPT "&Cancel   " LEFT 2007;
         ACTION ( lClose := .t.,lOK := .F., oREQ:END() )

//----------------------------------
Static Func CUSTGET( cNAME, cMODE, oRsReq, oButt1,oButt2,oButt3,oButt4, cWhere  )

LOCAL oDLG,oLBX, oRsCust, cSQL, oERR, oCol
LOCAL oBTN1,oBTN2,oBTN3,lOK,oBrush

msginfo( lclose )


As you can see from the screen shot .. the valid fires before the lclose variable is initialized and I can not seem to trap the event and return(.t.) from the valid ..

Thanks
Rick Lipkin

Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Cancel on Valid
Posted: Thu Dec 08, 2011 07:39 PM

Try adding
oBUTT2:lCancel := .t.

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Cancel on Valid
Posted: Thu Dec 08, 2011 08:45 PM
Gale

How would I trap that in the Valid function if the cursor is in the Get field ??

Code (fw): Select all Collapse
REDEFINE BTNBMP oBUTT2 ID 112 of oREQ   ;    // cancel
         RESOURCE "CANCEL1","DCANCEL1","DCANCEL1" ;
         PROMPT "&Cancel   " LEFT 2007;
         ACTION ( lOK := .F., oBUTT2:lCancel := .t., oREQ:END() )


I inserted your suggestion but the valid still fires if the cursor is in the Customer last name field ??

Code (fw): Select all Collapse
REDEFINE GET oClname        VAR cClname        ID 120 of oREQ PICTURE "@!" ;
            valid CustGet(cClname, cMODE, oRsReq, oButt1,oButt2,oButt3,oButt4, "1") UPDATE


Thanks
Rick Lipkin
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Cancel on Valid
Posted: Thu Dec 08, 2011 10:20 PM
Rick:

With the BUTTON class I do this way

Code (fw): Select all Collapse
    REDEFINE BUTTON oCancelar ID 902 OF oDlg UPDATE CANCEL;
        ACTION oDlg:END();
        MESSAGE "Cancela el proceso"


Pls note the CANCEL clause, perhaps these can help you

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Cancel on Valid
Posted: Thu Dec 08, 2011 10:23 PM
You need to do it like this:
Code (fw): Select all Collapse
REDEFINE BTNBMP oBUTT2 ID 112 of oREQ   ;    // cancel
         RESOURCE "CANCEL1","DCANCEL1","DCANCEL1" ;
         PROMPT "&Cancel   " LEFT 2007;
         ACTION ( lOK := .F., oREQ:END() )
oBUTT2:lCancel := .t.


This allows to Button to fire and ignore the valid function.
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Cancel on Valid
Posted: Thu Dec 08, 2011 10:25 PM

I don't think the Cancel clause works on btnbmp class. You have to use oButton:lCancel := .f.

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Cancel on Valid
Posted: Thu Dec 08, 2011 11:13 PM
Gale

YES .. your advice worked GREAT .. oButton:lCancel := .t. allowed the valid NOT to fire if the cursor was in the Valid Get !

Thanks
Rick Lipkin

Code (fw): Select all Collapse
REDEFINE BTNBMP oBUTT2 ID 112 of oREQ   ;    // cancel
         RESOURCE "CANCEL1","DCANCEL1","DCANCEL1" ;
         PROMPT "&Cancel   " LEFT 2007;
         ACTION ( lOK := .F., oREQ:END() )
         oButt2:lCancel := .t.

Continue the discussion