Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

closing formsets

Status
Not open for further replies.

kenndot

Programmer
May 15, 2001
316
US
I have a READ EVENTS that starts everything in my main prg, and in an Exit button I have CLEAR EVENTS, which is supposed to, according to the MSDN, throw the focus to the line immediately following READ EVENTS, which in my case is a function that closes/exits everything.

However, this does not actually happen. When I hit the CLEAR EVENTS, it returns me back to READ EVENTS and not the line following it, so the program never really exits.

Any ideas? Is there a problem with using Do Form and READ EVENTS for formsets? Appreciate any ideas! Thanks
 
Kinda.

When you issue CLEAR EVENTS, the main program file continues after the READ EVENTS line. However, if you still have parts of your FormSet open, the program may not exit properly. Make sure your exit button releases the FormSet before issuing CLEAR EVENTS.
 
I am closing everything (so I think) It is my understanding that I don't have to close each object explicitly. Is this not true?

I have my form where the Exit button is, then I'm closing releaseing and clearing the events in the formset destroy method, which should put me back to the line following READ EVENTS but it brings me back to READ EVENTS instead.

Do forms being modal/modeless have anything to do with how it closes? Or the ShowWindow Property?

 
Absolutely. If you have any Modal forms open, the program cannot continue until they have closed.

While in general VFP doesn't require that you close each object explicitly, it is still a good idea to close the ones you can. For example, closing a form will automatically release most of its resources. However, if there are ANY object references to ANY part of it, the form will just hand until those references are cleared.

As a general rule, I handle all of my cleanup manually. It makes debugging SO much easier.

Ian
 
Gah...

hang...HANG...the form will just HANG...

My fingers can't agree on whose turn it is sometimes...

Ian
 
Have you checked your data sessions ? If you are left with an unknown datasession, this means some object could not be released.
When this happens, you should check what object is linked to the datasession (probably your formset) and check why it isn't closed/released.

HTH,
Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
Thanks for the responses, and I will be checking everything you mentioned, however just one response of my own..

ChPicker,

You mentioned having modal forms... I read in MSDN that it doesn't matter WHAT you set the individual property to, it ('it' meaning each forms' windowtype property)automatically assumes the property that you have the formset set to.

Unless you specify it manually in the code, which I have not. So, if my formset is set to modal, then do I have to clear it in the destroy method? or somehow else manually? How would you think that works?
 
If your formset is set to Modal, then nothing will clear until the formset is released. The simplest thing I can think of is to have your Exit button do this:
Code:
ThisFormSet.Release()
Does that work?

Ian
 
That's what I've had in there in the Formset Destroy method all along. You just got me thinking though. I had set the formset to modal and when I read what you just said about it not closing/releasing anything else until that's closed then I figured that regardless of whether or not I was explicity releasing everything, it wasn't actually getting released because the formset was modal. And sure enough the event sequence doesn't try to close the formset until the very end and it wasn't doing that either because all the other objects were still open. It was sorta like a catch 22. THANKS!!!!!

I changed the property to modeless and it fixed EVERYTHING!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top