Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it a bug for code-execution order?
Message
De
07/11/2007 05:01:15
 
 
À
06/11/2007 19:57:21
Lu Ping
Zhuhai Tec Co.
Zhuhai, Chine
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01267162
Message ID:
01267202
Vues:
12
I think the .Destroy() will occur in the Release order specified with the exception of the window that currently has focus. The .Destroy() for this will only occur after CloseMe() completes. Experiment with this:
SET PROCEDURE TO dx
ON KEY LABEL CTRL+A do closeme

PUBLIC o1, o2 ,o3, o4
o1 = CREATEOBJECT([t1])
o1.Caption = "First"
o2 = CREATEOBJECT([t1])
o2.Caption = "Second"
o3 = CREATEOBJECT([t1])
o3.Caption = "Third"
o4 = CREATEOBJECT([t1])
o4.Caption = "Fourth"
IF MESSAGEBOX([show t1 form as top window?] ,4 ,[]) = 6		
	*- press ctrl+a ,then execute MESSAGEBOX([closeme]) first ,then execute MESSAGEBOX([destroy])
	o4.Show
	o3.show
	o2.Show
	o1.show
ELSE 
	*- press ctrl+a ,then execute MESSAGEBOX([destroy]) first ,then execute MESSAGEBOX([closeme]) 
	o1.show
	o2.Show
	o3.show
	o4.Show
ENDIF 

DEFINE CLASS t1 as Form 
	PROCEDURE destroy
		MESSAGEBOX([destroy]+THISFORM.Caption)
	ENDPROC 
ENDDEFINE 

PROCEDURE closeme
	RELEASE o4
	RELEASE o3
	RELEASE o2
	RELEASE o1
	MESSAGEBOX([closeme])
	ON key 
ENDPROC
>Different code-execution order by whether t1 window is current active window.
>The test code below.
>Thanks for anyone's test.
>
>
>SET PROCEDURE TO xd
>ON KEY LABEL CTRL+A do closeme
>
>PUBLIC o1 ,o3
>o1 = CREATEOBJECT([t1])
>o3 = CREATEOBJECT([t2])
>IF MESSAGEBOX([show t1 form as top window?] ,4 ,[]) = 6		
>	*- press ctrl+a ,then execute MESSAGEBOX([closeme]) first ,then execute MESSAGEBOX([destroy])
>	o3.show
>	o1.show
>ELSE
>	*- press ctrl+a ,then execute MESSAGEBOX([destroy]) first ,then execute MESSAGEBOX([closeme])
>	o1.show
>	o3.show
>ENDIF
>DEFINE CLASS t1 as Form
>	PROCEDURE destroy
>		MESSAGEBOX([destroy])
>	ENDPROC
>ENDDEFINE
>
>DEFINE CLASS t2 as Form
>	ADD OBJECT c1 as commandbutton
>	PROCEDURE c1.click
>		=cl()
>	ENDPROC
>ENDDEFINE
>
>
>PROCEDURE closeme
>	RELEASE o1
>	RELEASE o3
>	MESSAGEBOX([closeme])
>	ON key
>ENDPROC
>
>PROCEDURE cl
>	=closeme()
>ENDPROC
>
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform