Cancel on Valid

Cancel on Valid

Postby Rick Lipkin » Thu Dec 08, 2011 4:22 pm

To All

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

Code: Select all  Expand view


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

Image
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Cancel on Valid

Postby Gale FORd » Thu Dec 08, 2011 7:39 pm

Try adding
oBUTT2:lCancel := .t.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Cancel on Valid

Postby Rick Lipkin » Thu Dec 08, 2011 8:45 pm

Gale

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

Code: Select all  Expand view

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: Select all  Expand view

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

 


Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Cancel on Valid

Postby Armando » Thu Dec 08, 2011 10:20 pm

Rick:

With the BUTTON class I do this way

Code: Select all  Expand view

    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
User avatar
Armando
 
Posts: 3218
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Cancel on Valid

Postby Gale FORd » Thu Dec 08, 2011 10:23 pm

You need to do it like this:
Code: Select all  Expand view

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.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Cancel on Valid

Postby Gale FORd » 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.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Cancel on Valid

Postby Rick Lipkin » 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: Select all  Expand view

REDEFINE BTNBMP oBUTT2 ID 112 of oREQ   ;    // cancel
         RESOURCE "CANCEL1","DCANCEL1","DCANCEL1" ;
         PROMPT "&Cancel   " LEFT 2007;
         ACTION ( lOK := .F., oREQ:END() )
         oButt2:lCancel := .t.
 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 75 guests