Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to really cancel a form?
Message
De
21/04/2005 12:58:41
 
 
À
21/04/2005 12:35:43
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Database:
Visual FoxPro
Divers
Thread ID:
01007086
Message ID:
01007112
Vues:
21
PUBLIC oMyform
oMyform=NEWOBJECT("form1")
oMyform.Show
RETURN

DEFINE CLASS form1 AS form

	ADD OBJECT cmdCancel AS commandbutton WITH ;
		Top = 10, ;
		Left = 256, ;
		Height = 24, ;
		Caption = "Cancel",;
		Cancel = .F.	

	ADD OBJECT text1 AS textbox WITH ;
		Left = 10, ;
		Top = 10, ;
		Width = 100

	PROCEDURE text1.Valid
		RETURN !EMPTY(this.value)
	ENDPROC

	PROCEDURE cmdCancel.Click
		IF THISFORM.cmdCancel.Cancel
			thisform.Release()
		ELSE
			RELEASE WINDOWS (WONTOP())	&& AS CLICK ON x BUTTON
		ENDIF
	ENDPROC

ENDDEFINE
Fabio

>Hi,
>
>I have a form with several controls on it. There is a "Cancel" button that I want to be able to select at anytime to close the form and discard all changes. The problem is that if a control has focus and has valid code in it that prevents it from losing focus, the "Cancel" button is useless. Try the following code:
>
>PUBLIC oMyform
>oMyform=NEWOBJECT("form1")
>oMyform.Show
>RETURN
>
>DEFINE CLASS form1 AS form
>
>	ADD OBJECT cmdCancel AS commandbutton WITH ;
>		Top = 10, ;
>		Left = 256, ;
>		Height = 24, ;
>		Caption = "Cancel"
>		
>	ADD OBJECT text1 AS textbox WITH ;
>		Left = 10, ;
>		Top = 10, ;
>		Width = 100
>		
>	PROCEDURE text1.Valid
>		RETURN !EMPTY(this.value)
>	ENDPROC
>
>	PROCEDURE cmdCancel.Click
>		thisform.Release()
>	ENDPROC
>
>ENDDEFINE
>
>
>If you enter the textbox and try to immediately Cancel, you cannot until you actually type something in the textbox!
>
>Anyone know how to get around this annoying behavior? VFP9?
>
>TIA
>
>Regards,
>
>Mike
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform