Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Releasing forms programmatically
Message
From
19/12/2022 20:27:14
 
 
To
19/12/2022 11:50:21
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01685522
Message ID:
01685527
Views:
59
>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:
>
>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.
>


Hi Tamar.

I'd suggest the following -
1) go through the forms backwards.
2) If a form fails try another pass.
So, basically (without error checking) -
llProcess = .T.
Do While llProcess And _Screen.FormCount > 0
	llProcess = .F.
	For i = _Screen.FormCount To 1 Step -1
		Try
			_Screen.Forms[i].Release()
			llProcess = .T.
		Endtry
	Endfor
Enddo
Hopefully that will help.
Ian Simcock
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform