Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Form class and data environment
Message
De
02/09/2001 19:55:47
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, États-Unis
 
 
À
02/09/2001 12:22:54
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00551124
Message ID:
00551651
Vues:
31
This message has been marked as a message which has helped to the initial question of the thread.
Hi John, Nancy,
Yes, you must call the OpenTables() when using a PRG. My can move the OpenTables method call to the Init of MyDE...
DEFINE CLASS MyDE AS DATAENVIRONMENT
PROCEDURE Init
IF This.AutoOpenTables
   This.OpenTables()
ENDIF
>Hi, John-
>
>>I understand that the class doesn't have a DE. Are you saying that a form created (i.e. newobject('myform','formclass',...)) doesn't have a DE unless I specifically code it into the base class as in your example?
>
>Correct. That is what the example demonstrates.
>
>> If I open a table in such a form, then I must specifically close it, just as in a .prg, right?
>
>Not necessarily. You can use the DE's CloseTables() method The following is a better example, I hope, for your situation. Note: I couldn't get AutoOpen and AutoClose to work in a programmatic DE. I'm not sure if it should, or not.
>
>
*!*
>*!* NoDESample.PRG
>*!*
>
>IF !FILE('TEMP.DBF')
>	CREATE TABLE TEMP (c1 C(10))
>	INSERT INTO TEMP (c1) VALUES ("BAR")
>ENDIF
>
>IF USED('Temp')
>	USE IN TEMP
>ENDIF
>
>LOCAL ox
>ox = NEWOBJECT("MyForm")
>ox.SHOW(1)
>
>DEFINE CLASS MyDE AS DATAENVIRONMENT
>	AUTOOPENTABLES = .F.
>	AUTOCLOSETABLES = .F.
>	INITIALSELECTEDALIAS = "temp"
>	ADD OBJECT Cursor1 AS Cursor1
>ENDDEFINE
>
>DEFINE CLASS CURSOR1 AS CURSOR
>	ALIAS = "temp"
>	CURSORSOURCE = "temp.dbf"
>	NAME = "Cursor1"
>ENDDEFINE
>
>DEFINE CLASS MyForm AS FORM
>	DATAENVIRONMENT = .NULL.
>
>	PROCEDURE LOAD
>		THIS.DATAENVIRONMENT = NEWOBJECT("MyDE" )
>		THIS.DATAENVIRONMENT.OPENTABLES()
>	ENDPROC
>
>	PROCEDURE DESTROY
>		THIS.DATAENVIRONMENT.CLOSETABLES()
>	ENDPROC
>
>	PROCEDURE INIT
>		THIS.ADDOBJECT("Grid1", "Grid")
>		THIS.Grid1.RECORDSOURCE = "Temp"
>		THIS.Grid1.VISIBLE = .T.
>	ENDPROC
>
>	PROCEDURE UNLOAD
>		THIS.DATAENVIRONMENT = .NULL.
>	ENDPROC
>
>ENDDEFINE
Charlie
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform