Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Form class and data environment
Message
De
30/08/2001 23:22:11
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
 
 
À
30/08/2001 17:21:37
John Deupree
Long Term Care Authority
Tulsa, Oklahoma, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00551124
Message ID:
00551212
Vues:
26
This message has been marked as the solution to the initial question of the thread.
>I have a form class I have been using for data input for reports (dates, etc.). It is subclassed from my form base class. I instanciate this class in code using newobject..., set some properties, show the form (modal), grab the info I need from form properties and release the form.
>
>I added some code in the load of the base class that referenced the data environment. Forms that I design using this class run fine. However, the subclassed form won't run (instanciated from code). The error says 'Unknown member dataenvironment'. I'm assuming that it's because the DE doesn't exist yet? When does the DE get created? Do I need to base my subclass on a class that doesn't have the DE code in the load event?

A form class doesn't have a DateEnvironment. If you open your class and then right click you'll see that there isn't the DE option you have in an SCX. You would want to add one during instantiation.

Here is an example.
CREATE TABLE TEMP (c1 C(10))
INSERT INTO TEMP (c1) VALUES ("FOO")
INSERT INTO TEMP (c1) VALUES ("BAR")
GO TOP IN TEMP

LOCAL ox
ox = NEWOBJECT("MyForm")
ox.SHOW(1)

DEFINE CLASS MyDE AS DATAENVIRONMENT
	ADD OBJECT TEMP AS CURSOR WITH ;
		ALIAS = "TEMP", ;
		CURSORSOURCE = "C:\TEMP\TEMP.DBF"
ENDDEFINE

DEFINE CLASS MyForm AS FORM
	DATAENVIRONMENT = .NULL.

	PROCEDURE LOAD
		THIS.DATAENVIRONMENT = NEWOBJECT("DataEnvironment" )
		THIS.DATAENVIRONMENT.OPENTABLES()
	ENDPROC

	PROCEDURE INIT
		THIS.ADDOBJECT("Grid1", "Grid")
		THIS.Grid1.RECORDSOURCE = "Temp"
		THIS.Grid1.VISIBLE = .T.
	ENDPROC

	PROCEDURE UNLOAD
		THIS.DATAENVIRONMENT = .NULL.
	ENDPROC

ENDDEFINE
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform