Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Windows close button
Message
 
 
To
02/12/2005 11:23:22
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01074279
Message ID:
01074290
Views:
15
Tim,

Here is the sample of CancelValidation method Re: How to find the shortkey and the lastkey value? Thread #1074037

If you put NODEFAULT in QueryUnload, your form would not be closed. Here is the code from MereMortlas framework:
LOCAL lnReply, lnGoToPageOnCancel, lnRetVal

lnGoToPageOnCancel = 0

IF !CBaseForm::QueryUnload()
  NODEFAULT
  RETURN .F.
ENDIF

*--------------------------------------------
*-- Write out the contents current control
*--------------------------------------------
IF !this.WriteBuffer()
  NODEFAULT
  RETURN .F.
ENDIF

*---------------------------------------------
*--- Cancel all "new and empty" records in all
*--- business objects on the form
*---------------------------------------------
lnRetVal = This.CancelAllNewAndEmpty()

*----------------------------------------------------
*-- If adding a new record but nothing entered yet
*----------------------------------------------------
IF lnRetVal = FILE_OK
	*----------------------------------------------------
	*--- If the record has been changed by the user...
	*----------------------------------------------------
	IF This.IsChanged()
		*--------------------------------------------
		*--- If this form has an nGoToPageOnCancel
		*--- property, set it to zero so another
		*--- page is not activated upon selecting
		*--- Yes or No to AskToSave()
		*--------------------------------------------
		IF PEMSTATUS(This,"nGoToPageOnCancel",5)
			lnGoToPageOnCancel = This.nGoToPageOnCancel
			This.nGoToPageOnCancel = 0
		ENDIF
		*---------------------------------------
		*--- Ask if they want to save changes
		*---------------------------------------
		lnReply = This.AskToSave()
	   IF lnReply = IDCANCEL OR lnReply = IDMUSTKEY
	   	*-------------------------------------------
	   	*--- Reset the nGoToPageOnCancel property
	   	*--- if it has been changed.
	   	*-------------------------------------------
			IF lnGoToPageOnCancel != 0
		   	This.nGoToPageOnCancel = lnGoToPageOnCancel
		   ENDIF
			NODEFAULT
			RETURN .F.
		ENDIF
	ENDIF
ENDIF
>It is my understanding that if I let my forms have a close button, when the user clicks on the close button, the form will close and there is nothing my code can do to stop the close. I can get control in QueryUnload (and save the data in the form if it passes all the validations or throw it away if it fails the validations). In Word if I click on the close button in the upper right, I am given the option to stop the close (if there is unchanged stuff in the document). My VFP apps should behave the same way. What do I do?
>
>
>2nd question--
>
>I do the validations on each field in the field's Valid method (and again in the OK button click) so the user can get instant feed back. If MDOWN is true or Escape is hit I do not run the field Valid method ('cause the user is or may be going to the Cancel button). When the form close button is clicked, MDOWN is unaware and my validations in the field with focus are run. Not cool. How can my Valid methods figure out that they are running because the form close button has been clicked)? The best I can figure at the moment is keep track of the mouse postion in the form's MouseMove. If the y position is zero when a field Valid attempt to run, assume that the title bar is being clicked and don't run. There must be a better way.
>
>Thanks.
>
>Tim
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform