Draw, Paint

So what's the difference between drawing and painting? Seems to us you use brushes to paint, but you hold the colors in your hands to draw, like with a pencil or crayon.Wait a minute, not that kind of draw and paint. The FoxPro kind. Draw is a method you can call on to have a form redisplayed. Paint is an event that fires every time the form needs to be redisplayed because of changes. Toolbars also have a Paint event, but not a Draw method.

Usage

PROCEDURE frmForm.Draw | oObject.Paint
Draw is similar to Refresh, but doesn't update the data in controls—it only redraws them. We really can't see when we'd use Draw, but we're sure someone will find a clever way to exploit it.Paint is more interesting. It gets called a lot. Paint fires anytime a visual aspect of the form or toolbar changes, except for a control being used as intended. For example, Paint fires when focus changes because the focus rectangle has to be redrawn. Paint fires when the form loses focus because the title bar color changes. Paint fires when resizing uncovers part of a control. For a toolbar, Paint fires when you resize, dock or undock it and when you click on it to use it (we're not sure why on that last one).Paint fires often enough that you don't want to put too much in there because it can bog things down. As with Draw, we're not clear yet on when we'd want to use Paint, but we're certain the time will come when we're glad it's there.

Example

* You can see what fires Paint by putting the following in the 
* Paint method
DEBUGOUT "Paint fired - "+This.Name 

See Also

ClipControl, Hide, Refresh, Show


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .