Well, you only need to validate when u r saving some data, right.
So, from the queryunload() u call the save() method, and it calls a beforesave()
method where u check your data.
Therefore u only save if your data is ok, if it is not and u want to leave the 
form, u just don´t
save the data.

E.



On Friday, March 7, 2014 7:59 PM, Gene Wirchenko <ge...@telus.net> wrote:
 
Dear Vixens and Reynards:
>
>      What happens when one closes a form with a grid on it and 
>validation is set off?
>
>      Well, interestingly/frustratingly enough, the form's 
>QueryUnload does not fire until after the current control's 
>LostFocus.  This means that you can not code to ignore the validation 
>because the form is closing anyway.  Well, not cleanly that I can 
>see.  One can kludge something with amouseobj() as I have below (not 
>with a grid yet).  This works, but is a kludge.  Is there a better way?
>
>      Run this, and click somewhere.  The close button is of 
>particular interest.
>
>***** Start of Included Code *****
>* tmpclose
>* Experimenting with Form Closing
>* Last Modification: 2014-03-07
>
>#include "foxpro.h"
>
>    ? "*** Execution begins."
>    ? program()
>    close all
>    clear all
>
>    *
>
>    oForm=createobject("TestForm")
>    oForm.show()
>    read events
>
>    *
>
>    close all
>    clear all
>    ? "*** Execution ends."
>    return
>
>
>
>define class TestForm as form
>
>    procedure init
>
>       this.addobject("tb1","TestTextbox",10,10)
>       this.tb1.visible=.t.
>
>       return .t.
>
>       endproc
>
>    procedure queryunload
>
>       clear events
>
>       return
>
>       endproc
>
>    enddefine
>
>
>
>define class TestTextbox as textbox
>
>    procedure init
>    lparameter ptop, pleft
>
>       this.top=ptop
>       this.left=pleft
>
>       this.height=20
>       this.width=40
>
>       return .t.
>
>       endproc
>
>    procedure lostfocus
>
>       local mousie(4)
>
>       =amouseobj(mousie)
>
>       activate screen
>       ? mousie(1),this.objtype(mousie(1))
>       ? mousie(2),this.objtype(mousie(2))
>       ? mousie(3)
>       ? mousie(4)
>
>       if mousie(1)=thisform and mousie(4)<0
>          activate screen
>          ? "Apparently, the close button was clicked."
>       else
>          activate screen
>          ? "unknown action"
>          endif
>
>       return
>
>       endproc
>
>    procedure objtype
>    lparameter oObj
>
>       do case
>       case type("oObj")#T_OBJECT
>          retval="not an object"
>       case isnull(oObj)
>          retval="null object"
>       case oObj=thisform
>          retval="thisform object"
>       otherwise
>          retval="non-null, unknown object"
>          endcase
>
>       return retval
>
>       endproc
>
>    enddefine
>***** End of included Code *****
>
>Sincerely,
>
>Gene Wirchenko
>
>
>_______________________________________________
>Post Messages to: ProFox@leafe.com
>Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
>OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
>Searchable Archive: http://leafe.com/archives/search/profox
>This message: http://leafe.com/archives/byMID/profox/
>** All postings, unless explicitly stated otherwise, are the opinions of the 
>author, and do not constitute legal or medical advice. This statement is added 
>to the messages for those lawyers who are too stupid to see the obvious.
>
>
>

--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/1394234503.95069.yahoomail...@web163401.mail.gq1.yahoo.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to