Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Releasing forms programmatically
Message
From
19/12/2022 11:50:21
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Releasing forms programmatically
Miscellaneous
Thread ID:
01685522
Message ID:
01685522
Views:
125
In a complex application, we've set up a timeout (based on the code I published here: http://www.tomorrowssolutionsllc.com/Articles/Taking%20Advantage%20of%20Idle%20Cycles.PDF) that shuts down the application if the user does nothing (no keystrokes, no mouse movements) within a specified time. It works well, except in one situation.

If the user has stopped with a modal form open on top of another modal form on top of a modeless form, the code to close all the forms fails. Here's the code:
FOR lnForm = 1 TO _screen.FormCount
   TRY 
      loForm = _screen.Forms[1]
   CATCH 
      loForm = .null.
   ENDTRY 
   
   IF NOT ISNULL(m.loForm)
      *-- TEG 8/6/2020 
      * Wrap in TRY-CATCH in case of problems
      TRY 
         loForm.Release()
      CATCH TO loException
         do LogError with "Form " + loForm.Name + " (" + loForm.Caption + ") wouldn't closed", ;
                          loException.Message, "", .t., .t., .t.
         llProceed = .F.
      ENDTRY 
      
      IF NOT m.llProceed
         EXIT 
      ENDIF 
   ENDIF 
ENDFOR 
What happens is that the modal form on top closes, but the one below it doesn't. When its Release method is called, nothing happens--no events fire. That same form remains first in the Forms collection, so we spend the remaining passes through the loop just trying to release that form.

If we have a single modal form open over a non-modal form, all is well and things shut down as expected. I don't think this application has any cases where we can have a modal form over a modal form without a non-modal form underneath, so I can't test that.

I'm pretty sure the issue has to do with the code the modal form leaves "hanging." That is, in this application, pretty much every modal form is called as a function and there's a same-named program that sets things up and runs the modal form. I think I need to find some way to end that code as well, but I'm blanking on how to do that.

Any suggestions?

Tamar
Next
Reply
Map
View

Click here to load this message in the networking platform