Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Example of form that won't release in VFP7
Message
From
10/10/2001 22:24:30
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Example of form that won't release in VFP7
Miscellaneous
Thread ID:
00566754
Message ID:
00566754
Views:
55
Here is some code that fails in VFP7 and works in VFP6
It's important to anyone using assign methods with form objects (and perhaps others)
This code creates a simple form and assigns the form to a property of a custom object. If this involves an "assign" method, then the form does not release.
This is important to me since all my applications use a form manager class which coordinates forms with toolbars etc.

If you rename the oH.oFrm_assign() method to anything else, hence cancelling the assign method, the form will release properly!
The debugger shows that oH has NO objects attached after the form is released.
Issue CLEAR ALL in the command window to release the form after the program is run.
oh= CREATEOBJECT('oh')
oFrm= CREATEOBJECT('form1')
oFrm.show()

READ EVENTS

DEFINE CLASS form1 AS form
	Caption = "Standard Form"
	Name = "Form1"
	Height= 80
	Width= 180

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 15, ;
		Left = 25, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Close", ;
		Name = "Command1"

	PROCEDURE Init
		oh.frm(thisform)
	ENDPROC

	PROCEDURE command1.Click
		CLEAR EVENTS
	ENDPROC
ENDDEFINE

DEFINE CLASS oh AS custom
	ofrm = .NULL.
	Name = "oh"

	PROCEDURE frm
		lparameter oFrm
		this.oFrm= m.oFrm
	ENDPROC

	* This is the offender...
	PROCEDURE ofrm_assign
		LPARAMETERS vNewVal
		this.ofrm = m.vNewVal
	ENDPROC
ENDDEFINE
Next
Reply
Map
View

Click here to load this message in the networking platform