Microsoft KB Archive/136901

= How to Determine the Firing Order of Form and Object Events =

Article ID: 136901

Article Last Modified on 2/15/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q136901



SUMMARY
This article demonstrates how to determine the order in which events and methods are processed for any form.



MORE INFORMATION
Understanding the order in which events and methods are processed can help you place event and method code properly.

Step-by-Step Demonstration
 Create a free table that has a single 20-character field. From the Command window, type: CREATE TABLE myorder (event c (20)), or follow these steps:

 On the File menu, click New. In the New dialog box, click Table, and then click the New File button. Name the table Myorder. Create the single field. Name it Even, and give it a Character data type with a length of 20 characters. Click OK to save it. Don't enter any records.  Create or open a form for which you want to determine the firing order for the methods and events.</li>  Place the following code in all the event procedures and methods of the form and the objects it contains: ccur_alias=ALIAS     && Capture the form's table name, if any SELECT myorder         && The table recording the order APPEND BLANK =MESSAGEBOX(PROGRAM)     && Optional for visual effect REPLACE event WITH PROGRAM SELECT (ccur_alias)        && Returns to the form's table name To speed up this process, type the code once, copy it, and then paste it into each event procedure.

When determining which events to include, consider including the Destroy event for each object, so you can see the order in which objects are destroyed. Basically, Visual FoxPro uses the LIFO method (last in, first out) for destroying objects. </li> Open the table (Myorder), and run the form. After exiting the form, browse the Myorder table.</li></ol>

The Myorder table will contain a record for each event or method as it was processed; this is the flow chart for the form.

There are a number of events that occur in any form, in the same order each time. The principal variation will be in the objects and the types of objects. For example, a single command button will differ from a command group where each button within the command group has its own individual Init and Destroy events, among others.

The order in which objects are loaded depends on the order in which they were created in the Form Designer. This also dictates the order in which they will be destroyed; they are destroyed in the reverse order of their creation.

Additional query words: VFoxWin debugging fire

Keywords: KB136901

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.