Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Destroying an object
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00046886
Message ID:
00047826
Vues:
30
>Oh, now I understand. This is getting ridiculous. If the event method is called manually the base class method is not called automatically, but if that same event method is called by an event the base class event method is called automatically. I guess this is justification enough never to call an event method directly!
>
>I would have much prefered if MS had told us that if we were going to override an event we had to place a DoDefault() at the end of our code so that at least the behaviour of a base class would be consistent with that of a subclass. They could even autoinsert the DoDefault() into any event method as the do with methods that have parameters.
>
>Thanks,
>Darrel
Darrel,

I think you are confusing apples and oranges here. Most event methods have no base class behavior, they just run when the event that they are associated with occurs. IOW, a Click has no default behavior, as a form's Destroy and Unload have no default behavior. The Form's Init and load also have no default behavior. There is no need to use a DoDefault in an event if you write code in it.

It is important to understand that calling the event method does NOT cause the event to occur. There are many nonevent methods that do have default behavior as teh Relaese will release the form, the SHOW will show the form. etc.

The other evetn method that I just realized has a defualt behavior is the KeyPress event which will process the keypress.

The key here is that if you write code in the KeyPress you DO NOT override teh default processing of that key, you MUST issue a NODEFAULT to surpress the processing of the key.

In this way the ddefault behavior of a base class method is different from inherited code in your class tree. The inherited code is overridden as soon as you write anything in a subclass method, but the default baseclass behavior is NOT overridden, it will occur after your code.

If you don't want it after your code but before your code then you need to do something like this;

* KeyPress event
PARAMETERS nKeyCode ...
DoDefault(nKeyCode ...)
* Your code here
NODEFAULT && surpress the automatic running of the default behavior
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform