Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to stop a form from closing
Message
De
14/03/2001 22:10:49
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00485131
Message ID:
00485159
Vues:
13
Ken,
*!* Release() Method
IF NOT THISFORM.CleanUpAndExit()
  NODEFAULT
ENDIF

*!* QueryUnload Method
IF NOT THISFORM.CleanUpAndExit()
  NODEFAULT
ENDIF

*!* CleanUpAndExit() Method
LOCAL llOkToQuit
llOkToQuit = .T.
IF lSomeCondition
  THISFORM.cmd1.SetFocus()
  llOkToQuit = .F.
ENDIF
RETURN llOkToQuit



>Cindy - thanks for the quick reply. I created a test form using your suggestion but I must have missed something. Two problems occur. If I close the form using the X, the CleanUpAndExit method fires but the form closes anyway. If I click on a Command Button that triggers the CleanUpAndExit method and my test condition is false, I get "Allowed DO nesting level exceeded" error. My CleanUpAndExit method looks something like this:
>
>If lcondition = .t. && Don't close form
>thisform.cmd1.setfocus
>else
>thisform.release
>endif
>
>
>Thanks again for your help and patience.
>
>>Ken,
>>
>>There are two ways to close a form - by calling THISFORM.Release(), (often code in an Exit button) or by the X, which fires QueryUnload(). Ultimately you must make sure your test runs by either close method.
>>
>>The best thing to do is to make a custom method like CleanUpAndExit() and put your test to see if you want to close in there. In each of the Release() and QueryUnload() methods, call THISFORM.CleanUpAndExit().
>>
>>You might put CleanUpAndExit in your base form class, and also the calls to it. Then in each form put whatever code you want to run when you clean up.
>>
>>If you don't want to exit, return .F. from CleanUpAndExit and SETFOCUS to whatever control you need to.
>>
>>
>>>Is there a way to test for a condition (eg. unsaved changes) when a form is closed (ie. user clicks the close icon on top right of form), abort the closing of the form and reset focus to a control?
>>>Thanks.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform