Microsoft KB Archive/142398

= How the Paint Event of a Form Works =

Article ID: 142398

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q142398



SUMMARY
In the Help file or reference manual for the Paint event, it says that the Paint event will fire when part or all of a form or toolbar is exposed after it has been moved or sized -- or after a window that was covering the form or toolbar has been moved.

This is true, but the Paint event also fires at other times, such as when a value of an object changes or when moving the cursor from one object to another object on the form. With this in mind, you should be aware of the consequences of certain code that is placed in the Paint event.



MORE INFORMATION
The Paint event is an event of the form and is useful for checking the status of objects, forms, variables, or a toolbar. It is wise to not place any code in the Paint event that would affect the size or appearance of any objects or properties. Changing the caption of an object or changing the value of an object on a form would be examples of code that would make the form act strange.

Example
 Create a form and add a new property for the form. On the Form menu, click New Property, and in the Name box, type:

numcount

In the Properties sheet under the Other tab, scroll to the bottom, and change the .F. beside the numcount property to the numeric value of 1. Add a text box to the form.  In the Paint event of the form, add the following code: THISFORM.NUMCOUNT = THISFORM.NUMCOUNT + 1 THISFORM.TEXT1.VALUE = STR(THISFORM.NUMCOUNT)  Run the form. Note that the text box is being regularly updated with a new number. This is because the Paint event is being called repeatedly. Every time the value of the text box is changed in Paint event, the Paint event is called again because it sees that the value of an object in the form has changed.

Additional query words: VFoxWin

Keywords: KB142398

-

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

© Microsoft Corporation. All rights reserved.