Index
2014-03-07 16:59 – Gene Wirchenko : Closing a Form with a Grid with a Control with Validation
2014-03-07 17:21 – Eurico Chagas Filho : Re: Closing a Form with a Grid with a Control with Validation
2014-03-10 12:07 – Gene Wirchenko : Re: Closing a Form with a Grid with a Control with Validation
2014-03-10 13:10 – Tracy Pearson : RE: Closing a Form with a Grid with a Control with Validation
Back to top
Closing a Form with a Grid with a Control with Validation

Author: Gene Wirchenko

Posted: 2014-03-07 16:59:32   Link

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.

©2014 Gene Wirchenko
Back to top
Re: Closing a Form with a Grid with a Control with Validation

Author: Eurico Chagas Filho

Posted: 2014-03-07 17:21:43   Link

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 <genew@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.YahooMailNeo@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.

©2014 Eurico Chagas Filho
Back to top
Re: Closing a Form with a Grid with a Control with Validation

Author: Gene Wirchenko

Posted: 2014-03-10 12:07:17   Link

At 16:21 2014-03-07, Eurico Chagas Filho <e28chagas@yahoo.com.br> wrote:

>Well, you only need to validate when u r saving some data, right.

No. I need it when changing rows, too.

>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.

My validation is also at the control

level. I need to detect the form close so I can

bypass that validation. The QueryUnload happens

after when I need to know that it will happen. Thus, my kludge code.

[snip]

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.

©2014 Gene Wirchenko
Back to top
RE: Closing a Form with a Grid with a Control with Validation

Author: Tracy Pearson

Posted: 2014-03-10 13:10:26   Link

Gene Wirchenko wrote on 2014-03-10:

> At 16:21 2014-03-07, Eurico Chagas Filho <e28chagas@yahoo.com.br> wrote:

> Well, you only need to validate when u r saving some data, right.

>

> No. I need it when changing rows, too.

>> 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.

>

> My validation is also at the control

> level. I need to detect the form close so I can

> bypass that validation. The QueryUnload happens

> after when I need to know that it will happen. Thus, my kludge code.

>

> [snip]

>

> Sincerely,

>

> Gene Wirchenko

Gene,

The form's ReleaseType property will be set before the LostFocus event is

fired.

Tracy Pearson

PowerChurch Software

_______________________________________________

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/000301cf3c8c$03824230$0a86c690$@powerchurch.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.

©2014 Tracy Pearson