dbTalk Databases Forums  

VFP 6: clear events with Nonmodal Forms

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss VFP 6: clear events with Nonmodal Forms in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gene Wirchenko
 
Posts: n/a

Default VFP 6: clear events with Nonmodal Forms - 08-17-2005 , 05:36 PM






You might recall my question not too long ago about
copy-cut-paste with toolbars. I am now looking at using nonmodal
forms. I have a couple of problems.

1) Where do I put the clear events command? If I do not have it, my
program does not terminate when all forms are closed. Since any form
might be the last, what is the best placement?

If I am using a menu, then presumably, I put it in the exit
selection, but if I am not using a menu, what do I do?

I suppose that I can have
if _screen.formcount=0 && or 1, I am not sure
clear events
endif
in a suitable event's (.unload()?) code, but it looks kludgy.

2) What is the best way to store the object references (so the forms
stay in scope)? A global array? Do you have hardcoded references to
array elements, search for a free element, or do something else?

Sincerely,

Gene Wirchenko


Reply With Quote
  #2  
Old   
Dan Freeman
 
Posts: n/a

Default Re: VFP 6: clear events with Nonmodal Forms - 08-17-2005 , 06:45 PM






Gene Wirchenko wrote:
Quote:
You might recall my question not too long ago about
copy-cut-paste with toolbars. I am now looking at using nonmodal
forms. I have a couple of problems.

1) Where do I put the clear events command? If I do not have it, my
program does not terminate when all forms are closed. Since any form
might be the last, what is the best placement?

If I am using a menu, then presumably, I put it in the exit
selection, but if I am not using a menu, what do I do?

I suppose that I can have
if _screen.formcount=0 && or 1, I am not sure
clear events
endif
in a suitable event's (.unload()?) code, but it looks kludgy.

2) What is the best way to store the object references (so the forms
stay in scope)? A global array? Do you have hardcoded references to
array elements, search for a free element, or do something else?
Most folks use a Forms collection of our own in our global application
object. In my case, the app object is our only public variable.

Form classes are tweaked so that when they start up, they "announce"
themselves to the Forms collection and it knows to store a reference. When
they're releasing, they notify the forms collection so it can remove their
reference. If you used a scheme like this, your Forms collection would be
the only place you'd need to put your shutdown code.

(Although not all apps SHOULD shut down when the last form closes, of
course.)

Either way, you're going to have to find some other way to maintain counters
than _screen.Formcount because it isn't decremented until your form is
actually gone, so there isn't a way to know it got to 0 in code in the form
itself.

Dan




Reply With Quote
  #3  
Old   
Jack Jackson
 
Posts: n/a

Default Re: VFP 6: clear events with Nonmodal Forms - 08-18-2005 , 12:25 AM



On Wed, 17 Aug 2005 15:36:41 -0700, Gene Wirchenko
<genew (AT) ucantrade (DOT) com.NOTHERE> wrote:

Quote:
You might recall my question not too long ago about
copy-cut-paste with toolbars. I am now looking at using nonmodal
forms. I have a couple of problems.

1) Where do I put the clear events command? If I do not have it, my
program does not terminate when all forms are closed. Since any form
might be the last, what is the best placement?

If I am using a menu, then presumably, I put it in the exit
selection, but if I am not using a menu, what do I do?

I suppose that I can have
if _screen.formcount=0 && or 1, I am not sure
clear events
endif
in a suitable event's (.unload()?) code, but it looks kludgy.
I think that's what you have to do, put the code in the Unload()
event, except I think the test should be for formcount==1.

Quote:
2) What is the best way to store the object references (so the forms
stay in scope)? A global array? Do you have hardcoded references to
array elements, search for a free element, or do something else?
I have a single application object with the only PUBLIC variable
holding a reference to the object. I would create an object to manage
the forms and put an instance of the object in the application object.

The form management object would at least need an array to hold the
references to the forms and an Add method. Form references are
replaced by .NULL. when the form is destroyed, so it isn't strictly
necessary to remove entries from the array when a form goes away. The
Add method could search for a NULL entry, and add a row if there isn't
one.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.