Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The proper use of the AutoYield property
Message
 
To
29/11/1997 12:22:12
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00062393
Message ID:
00065849
Views:
69
>>3. Since we have the possibility to subclass OCX controls, it should be a good practice for OCX's that receive focus to put _VFP.AutoYield = .F. in their GETFOCUS() and _VFP.AutoYield = .T. in their LOSTFOCUS().
>>4. For OCX controls that never receive the focus, find another way. Vlad suggests the following: "Assuming that you don't want to set it at the beggining of you app, I would say that you should have a global var or app property to keep the number of active OCX that need Autoyield = .F. You should increment it in Init and decrement it in Destroy. The ocx that decrements it to zero, resets it to .t."
>>
>>Another approach to 3 and 4 should be to add an lAutoYield property to the container or form that contains the .OCX and add the following code in the INIT()
>>*-- CHANGE - JCM - November 27, 1997 - 09:38:09
>>*-- this form contains an ActiveXControl that behaves much better
>>*-- with AutoYield set to .F.
>>
>>this.lOldAutoyield = _VFP.AutoYield
>>
>>IF this.lOldAutoYield = .T.
>> _VFP.AutoYield = .F.
>>ENDIF
>>
>>DODEFAULT()
>>*-- ENDCHANGE - JCM - November 27, 1997 - 09:39:53
>>
>>
>>And the container or Form DESTROY()
>>*-- CHANGE - JCM - November 27, 1997 - 09:38:09
>>*-- this form contains an ActiveXControl that behaves much better
>>*-- with AutoYield set to .F.
>>*-- Reset this property to its old value
>>
>>IF _VFP.AutoYield # this.lOldAutoyield
>> _VFP.AutoYield = this.lOldAutoyield
>>ENDIF
>>
>>DoDefault()
>>*-- ENDCHANGE - JCM - November 27, 1997 - 09:39:53
>>
>>What do you think?
>>
>>José
>
>I say that this approach will not work. This is event driven programming and you cannot apply the technique of save&restore of a setting. To be more clear, this will not work properly in the following event sequence:
>
>ActiveX1.Init && OldAutoYield = .t., AutoYield = .f.
>ActiveX2.Init && OldAutoYield = .f., AutoYield = .f.
>ActiveX1.Destroy && OldAutoYield = .t., AutoYield = .t.
>ActiveX2.Destroy && OldAutoYield = .f., AutoYield = .f.
>
>You will have Autoyield = .t. between the ActiveX1.Destroy and ActiveX2.Destroy. Also, the ActiveX2.Destroy will "reset" the value to .f., which is not correct. If you don't care about the value restored by the last Destroy... you can set it at the begging of your app (because it means that a value of .f. is ok for your app).
>
>This is why I proposed the global counter.
>
>Am I right?
>
>Vlad

Hi Vlad,

You still remember this thread? I posted my message then could not connect, then Michel came with v1.1 of the reader and I got lost...

I do agree with your approach. A global counter is needed.

José
Previous
Reply
Map
View

Click here to load this message in the networking platform