Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Order of object creating for a form
Message
From
21/06/1999 18:54:27
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00231124
Message ID:
00232261
Views:
19
>How does VFP5 determine the order of object creation when a form is called? I'm trying to get certain control to Initialize() before another. I though setting tab order will do it but I guess it doesn't. TIA.

Hi John,

One of the real limitations of VFP is that the programmer has no direct control over object firing order on a form. It is initially the order in which you add objects to a form, but it can be influenced in a limited way by the Zorder() method of an object.

It would be best if VFP provided a zordering method like it provides for setting tab order. In fact there is a zorderindex property of each object on the form which is not, however, exposed. I have tried with limited success to directly edit the zorderindex in the .sct, but I am not entirely confident that one can do so without getting in trouble.

So far, the best solutions I have found are (1) remove all of the objects from the form onto another temporary form, then move them back one at a time to the permanent form in the order in which you want them to fire or (2) bypass native firing order entirely and, at the form level, create an array of objects on the form which is sorted in the order in which you want objects to fire.

I use a property of the form, aObjects[] to hold a reference to each control on the form and its tabindex. Each object on the form adds itself to the array when it is initialized. When all objects are added, the array is sorted by tabindex order (or any other order you want, just substitute the order for tabindex).

This gets complicated if you use pageframes or containers on your form. What I do in that case is set up a separate array in each pageframe or container to hold references to the controls on that pageframe or container.

This framework gives you absolute control over the sequence in which events occur if you use in in place of the form's .controls array. The form will still use its native zorderindex for instantiating controls, but once they exist you have complete control over their event order by using the aObjects array.

Someday (when I get time, ho ho) I intend to mess around with the zorderindex property to see what can be done with it, but for right now these are the solutions I use.


regards,
Jim Edgar
Jurix Data Corporation
jmedgar@yahoo.com

No trees were destroyed in sending this message. However, a large number of electrons were diverted from their ordinary activities and terribly inconvenienced.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform