Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BINDEVENTS not always binding?
Message
De
23/12/2004 13:52:01
 
 
À
23/12/2004 08:25:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Divers
Thread ID:
00971677
Message ID:
00971865
Vues:
18
>You should avoid binding events as an object (or it's delegate object) is in the process of instantiation.
>
>Why is that? What kind of problems might this cause? While it seems to me the natural place to put it when having a class defined programmatically, I'd like to learn how to avoid it if I need to.

If an object is not instantiated, you can't bind it. This is not to say that you can never use the Init for binding. However, if you have a class which, for whatever reason, takes longer to Init, binding can fail. I learned this the hard way and it's buried in the docs somewhere.

>>
>>You should avoid binding events as an object (or it's delegate object) is in the process of instantiation.
>>
>>I have also found out that VFP9 breaks a key function of BINDEVENT. It will always return the return value of the event source and never that of the delegate no matter how the flags are set.
>>
>>>I'm trying to bind some events in a textbox in a column of a grid to methods in the grid. The code looks like this (done in the INIT of the textbox)
>>>
>>>
      lcEvent='Click'
>>>      BINDEVENT(THIS,lcEvent,THIS.PARENT.PARENT,'TextBox'+lcEvent)
>>>      lcEvent='RightClick'
>>>      BINDEVENT(THIS,lcEvent,THIS.PARENT.PARENT,'TextBox'+lcEvent)
>>>      lcEvent='GotFocus'
>>>      BINDEVENT(THIS,lcEvent,THIS.PARENT.PARENT,'TextBox'+lcEvent)
>>>      lcEvent='When'
>>>      BINDEVENT(THIS,lcEvent,THIS.PARENT.PARENT,'TextBox'+lcEvent)
>>>      lcEvent='Valid'
>>>      BINDEVENT(THIS,lcEvent,THIS.PARENT.PARENT,'TextBox'+lcEvent)
>>>      lcEvent='LostFocus'
>>>      BINDEVENT(THIS,lcEvent,THIS.PARENT.PARENT,'TextBox'+lcEvent)
>>>      lcEvent='InteractiveChange'
>>>      BINDEVENT(THIS,lcEvent,THIS.PARENT.PARENT,'TextBox'+lcEvent)
>>>      lcEvent='KeyPress'
>>>      BINDEVENT(THIS,lcEvent,THIS.PARENT.PARENT,'TextBox'+lcEvent)
>>>
>>>
>>>This works for six of the eight events. That is, I can verify that the method in the grid is invoked as expected, except for Valid and When.
>>>
>>>Any ideas why this would be true?
>>>
>>>Thanks,
- Jeff
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform