Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bindevent
Message
 
 
À
17/09/2004 15:25:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro Beta
Titre:
Divers
Thread ID:
00943600
Message ID:
00943785
Vues:
19
>I don't know if Bindevent behavior has changed in the beta, but thought I had success in creating both a beforeInit() and afterInit() event when playing with it in VFP8. I can have a BeforeInit(), or an AfterInit(), but not both.
>Anyway, while using VFP Beta, I'm unable to do so in a generic Report Form class. Currently I have a couple lines of code added to the bottom of each report's init(). It really belonged in the Report's baseclass, but it never made it.
>A change I'm about to do makes it more important to move it into the report form's baseclass - this code needs to run after the form's init has completed. I could place the code in some other event, but the bindevent seems like a reasonable choice.
>
>The following is the code I'm using:
>BINDEVENT(Thisform, 'Init', THISFORM, 'BeforeInit', 0)
>BINDEVENT(Thisform, 'Init', THISFORM, 'AfterInit', 1)
>

Hi Michael,

When I run following code in VFP87SP1 OR VFP9beta I see messages from BeforeInit(), Init() and afterInit(). Do you see anything different?
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"

	PROCEDURE beforeinit
		WAIT WINDOW PROGRAM()
	ENDPROC

	PROCEDURE afterinit
		WAIT WINDOW PROGRAM()
	ENDPROC

	PROCEDURE Init
		WAIT WINDOW PROGRAM()
	ENDPROC


	PROCEDURE Load
		BINDEVENT(Thisform, 'Init', THISFORM, 'BeforeInit', 0)
		BINDEVENT(Thisform, 'Init', THISFORM, 'AfterInit', 1)
	ENDPROC


ENDDEFINE
You can achive the same result w/o using BINDEVENT() if you're not planning to overwrite form's init. Something like
PROCEDURE Init
	= BeforeInit() 	
	* Your init code here
	...
	= AfterInit()
ENDPROC
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform