Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Clarifications please - BINDEVENT() and RAISEEVENT()
Message
De
22/04/2003 13:02:53
 
 
À
16/04/2003 09:57:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro Documentation de produit
Divers
Thread ID:
00778310
Message ID:
00780215
Vues:
23
>The new BINDEVENT() function has a nFlags parameter that defaults to 0, that value specifying "Call delegate code before event code.".
>Now a nFlags value of 2 is available and in this case it is used to specify "Do not trigger event (call delegate code) when a simple method call occurs.".
>
>Now the RAISEEVENT() "Remarks" starts with the following:
>Visual FoxPro does not automatically raise events for custom methods that are bound to objects using BINDEVENT( ) if the methods are called directly. For example, the following code does not raise an event:
oForm.GetMyData(cData)
Instead, to raise an event for a custom method, you need to make the following call:
>RAISEEVENT( oForm, "GetMyData", cData )
You can also change this behavior by using BINDEVENT( ) with nFlags set to 2 or 3.
>
>This looks contradictory to me in that the default of 0 in BINDEVENTS() should automatically call the custom method, should it not?

It's not contradictory, just obfuscated.
That documentation is not wrong, it contains all the correct facts.
Just not in a logical order :)


The oForm.GetMyData(cData) will not raise an event, that is perfectly true.

What they forgot to say, I think, is that if you call BINDEVENT() with the defaults it should still work in that case.

The only time that simple method calls do NOT work is if you specifically tell VFP not to handle it, with the second bit (values 2 or 3).
So the example code has a bit missing:
*** If you bind and tell VFP to ignore simple method calls
BINDEVENT( oForm, "GetMyData", MyObject, "Delegate", 2 )
*** Then this method call no longer fires the delegate, because no event is raised
oForm.GetMyData( cData )
*** This will fire the delegate in all cases, no matter what the nFlags value
RAISEEVENT( oForm, "GetMyData", cData )
So raise it as a DOC bug by all means !
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform