Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find and Close all Instantiated Forms
Message
From
03/12/2008 16:42:55
 
 
To
03/12/2008 16:23:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01365406
Message ID:
01365408
Views:
30
>Hello all. I have a timer that forces our Mere Mortals application to close. To ensure a graceful exit, I need to check for any forms open in the application and possibly call their unload/release etc event.
>
>I have seen goApp.oForms.GetFormCount() used, and a FOR loop as such:
>
>>>FOR EACH oForm IN _screen.Forms
>** do some magic to find form name and close it?
>
>
>I am having issues with a graceful (cannot access selected table errors) exit when simply calling OnShutDown() with an open form.

I'm not familiar with MM in particular, but does it perhaps have a goApp.Exit() method? The sort of thing you're trying to do here feels like something Kevin may have already baked into the framework.

A few other general points:

- if the user has data entry in progress, you may have to revert or roll back any changes made
- sometimes you need to be careful using collections when closing its members e.g. (pseudocode)
lnFormCount = goApp.oForms.GetFormCount()

FOR lnIx = lnFormCount TO 1 STEP -1
  goApp.oForms( lnIx ).SomeCloseMagic()

ENDFOR

* i.e. work from the end backwards, rather than from the start to the end.
* This prevents any problems when/if GetFormCount() or similar properties/methods decrement
* as you remove the collection's members.
- for the "cannot access the selected table" error, check Sergey's FAQ#18812

But again, it wouldn't surprise me if MM takes care of all this for you if you call the appropriate method(s).
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform