Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Don't close the form
Message
De
27/03/2007 17:12:44
 
 
À
27/03/2007 16:05:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01208976
Message ID:
01209022
Vues:
16
>>>>I have a form. On the form is a Pageframe with two pages. Each page has a ADD/SAVE button and a DONE/CANCEL button.
>>>>
>>>>If the use presses the "X" button, I want to validate that there are no unsaved changes.
>>>>
>>>>I've put the following code in various methods
>>>>NODEFAULT
>>>>WITH thisform.pageframe1
>>>>   IF .pages(.activepage).cmdAdd_Save.caption = "Save"
>>>>	=MESSAGEBOX("You have unsaved changes"+CHR(10)+"Please press <Save> or <Cancel>")
>>>>	RETURN .F.
>>>>   ELSE
>>>>	DODEFAULT()
>>>>   ENDIF
>>>>ENDWITH
>>>>
>>>>When I put this in the Form Release method the code didn't fire when I clicked the X.
>>>>
>>>>When I put this in the Form Unload method, the pageframe had already been unloaded and an error was generated.
>>>>
>>>>When I put this in the Destroy method, the messagebox popped up, but the form closed anyway.
>>>>
>>>>Similar syntax works correctly in the page Deactivate event.
>>>>
>>>>I could really use some advice on the correct event to code and the proper syntax to make this work the way I would like.
>>>>
>>>>Thanks to all.........Rich
>>>
>>>Validation code should go to Form.QueryUnload event.
>>
>>Thank you very much. One extra question if I may......
>>
>>This now works......but have I "properly" coded NODEFAULT and DODEFAULT()???
>>
>>Thanks again
>
>NODEFAULT should be used conditionally, i.e. it's fired when you don't want form to be closed, e.g.
>
>*** form.queryunload event
>IF This.CloseForm()=.F.  && closeform is custom method containing validation code
>  NODEFAULT
>ENDIF
>
>There is no need (generally) to use DoDefault() here unless your form is subclassed and you really want to execute parent class QueryUnload code.

Thanks to you and Fred both. Appreciate it.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform