Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Order of object creating for a form
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00231124
Message ID:
00231848
Views:
17
>> VFP determines the order to fire the Init methods(and other event processing) by the ZORDER property. This is the property is only affected by "Bring to Front" and "Send to Back" options in the designers. For the Init event, you are only assured that contained objects will fire their Init events before their containers (from inside to outside in container heirarchy). Although ZORDER controls the order of instantiation among objects that are at the same level in the containership heirarchy, it is not safe to rely on this order, it is too easy to disturb. Jim Booth's solutions are preferable to relying on this feature of VFP.
>
>I fully agree about the philosophy, but I'm not sure how Zorder() could control instantiation order generally, when objects are added to screen with all having same default Zorder of 0 at design...it must either be tab order or order of object-adding that controls instantiation order (of same-level objects)...
Hi Bruce,
Yep, believe it or not that's how it works. Take a look at the Hacker's Guide to VFP3 or 6, the entry for ZORDER describes what it is and how it is related to event processing. You are correct in the default case, the initial ZORDER *is* determined by the order in which an object is added.
When you add a new object to a form it is by default added at the top of the ZORDER stack(stored as the order of records in the SCX/VCX). I'm not sure what you mean by ZOrder=0 for a new object, there is an exposed ZOrder method that can have 0 as its parameter (which means put the chosen object at the top of the stack(fire its events last)). As Ted+Tamar note, VFP's developers had to control the order in which events fire somehow, and this is the approach that they chose.
You can test the behavior by adding a few objects to a form with DEBUGOUT statements in their Init's. By choosing each object in turn, invoking "Send to Back" and then instantiating the form, you will see that you are actually changing the order in which the control's Init methods are being fired.

Strange but true,

Ned
Ned

Reality is.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform