Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LISA G Who?
Message
De
04/12/2003 18:39:29
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
LISA G Who?
Divers
Thread ID:
00856120
Message ID:
00856120
Vues:
62
I have been generally aware of the order of Form events for some time but since I use Visual FoxExpress foundation (an older version) I haven't had to pay too much attention to the details.

Now I'm digging into what happens and I need to be a little more precise.

So here is the basic instantiation sequence (LISA G) as described in Wiki:

LOAD - great place for form-wide settings, manually opening tables or views and setting relations, so they are ready before bound controls Init (Form INIT is too late for that). Also here could establish an ADO recordset, or get a data object ready??

INIT - happens after LOAD and also after INIT of all controls and containers on the form, which Init from the inside-out. Put LPARAMETERS statement here to receive parameters passed to the form, but store them to form properties before INIT finishes, since they will go out of scope. Return .f. from INIT to shut down form instantiation.

Can talk to form controls/containers during form INIT, but don't SetFocus to them here, since that will short-circuit instantiation and fire ACTIVATE and GOTFOCUS in order to do the control's SetFocus.

SHOW - fires after INIT. _SCREEN.Activeform is still the previous form at this point, so you can grab a reference to the calling form for whatever purpose you might want -- right up to the end of SHOW.

ACTIVATE - Fires after SHOW. This form now is _SCREEN.Activeform. ACTIVATE also fires whenever you bring focus back to this form from somewhere else in the same application.

GOTFOCUS - fires after ACTIVATE.

http://fox.wikis.com/WC.DLL?Wiki~FormEvents~VFP

Now here is a test program and some trace output:
***************************************************************************
*&RS FUNCTION   DOFORM
***************************************************************************
* Purpose.....: Creates and shows forms, and returns values if appropriate
* Parameters..: tcClassName	-- name of form class to create
*				tuParm1		-- optional parameter to pass to form being created
* Example.....: DoForm("TESTFORM")
* Returns.....: result of CREATEOBJECT
* Created.....: 2003.12.04
* History.....: Adapted from DOFORM by Paul Bienick in CodeBook
**********************************************************************
function DoForm(tcClassName, tuParm1)

local	loObject
local	luRetVal

close database all

Trace_RS("DoForm--before CREATEOBJECT","PL")
	
set classlib to LIBS\TESTLIB.VCX
if PCOUNT() < 2
	loObject = createobject(tcClassName)
else
	loObject = createobject(tcClassName, @tuParm1)
endif

iif(glTrace_RS,Trace_RS("DoForm--before SHOW"), .f.)

if type("loObject") == "O" and !isnull(loObject)
	loObject.show()
	if type("loObject.uRetVal") <> "U"
		luRetVal = loObject.uRetVal
		loObject.destroy()
		release loObject
		wait window "UNABLE TO CREATE " + tcClassName
		return luRetVal
	endif
else
	iif(glTrace_RS,Trace_RS("DoForm--CREATEOBJECT failed " + tcClassName), .f.)
endif

iif(glTrace_RS,Trace_RS("DoForm--before READ EVENTS"), .f.)

read events
release loObject

Trace_RS("Q")

endfunc

 63358.402 DS1            DoForm--before CREATEOBJECT
 63360.726 DS1            TESTFORM.Load: testform 
 63360.726 DS1            TESTFORM.Init: testform 
 63360.726 DS1            DoForm--before SHOW
 63360.726 DS1            TESTFORM.Show: testform 
 63360.736 DS1            TESTFORM.Activate: testform 
 63360.736 DS1            DoForm--before READ EVENTS
 63360.746 DS1            TESTFORM.GotFocus: testform 
Note that TESTFORM is based on the FORM base class and there is no event code other than the calls to TRACE_RS.

So what I notice is that CREATEOBJECT automatically executes the LOAD event and then the INIT event but then it stops.

I have to explicitly call SHOW() as the next step and then ACTIVATE happens automatically. But not GOTFOCUS. That doesn't happen until after I execute READ EVENTS.

If READ EVENTS was already executing, I assume I would have to explicitly SetFocus() on one of the contained objects before GOTFOCUS would execute.

So it looks sort of like this to me:

LI (code) SA (code) G

Have I got this right? Any one have any clarifying comments?

Peter
Peter Robinson ** Rodes Design ** Virginia
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform