autoRedraw

Type: Boolean

Availability: Read or write at run time only

The autoRedraw property of the Window class applies to any form or control at run time only and specifies whether the drawing methods save a history of graphics commands issued for that form or control. This history of commands is replayed when the repainting of that window object is required, enabling the image to be automatically rebuilt. The autoRedraw property can be used to overcome the problem when graphics output on the object of a window is lost when that window is covered over and then uncovered.

To rebuild the image, you can:

Using the autoRedraw property has the following advantages over placing the calls to graphics methods in the paint event.

Because use of the autoRedraw property saves a history, there is a cost to its use. Take care to ensure that the history is cleared at appropriate points, by using the clearGraphics method, otherwise the history list consumes an increasing amount of memory, and the graphical presentation gets slower and slower as it has to process an increasing amount of history when repainting.

When you use the drawFilledRectangle or drawSolidRectangle method to draw a solid rectangle, previous figures that were drawn in the history but are covered and all property settings that have been made redundant are removed. In addition, the drawLine method removes any previous lines with the same co-ordinates where the same width and drawStyle property values apply. The automatic process does not occur if you use flood-fill, after logic calls to the drawSize method, or if the value of the drawMode property is not DrawMode_Copy (13).

The settings of the autoRedraw property are listed in the following table.

Setting Description
true Enables automatic repainting of a form or control. Graphics are written to the screen, and the commands used to create the image are saved in a history "file" in memory. The paint event of the object is not called, and the object is repainted when necessary, by using the memory image.
false Disables automatic repainting of an object, and writes graphics or print output to the screen only. The paint event of the object is invoked, allowing user logic to redraw the graphics (the default)

Changing the setting of the autoRedraw property from true to false automatically clears the graphics history but does not affect the image that is currently displayed.

Drawing properties are saved in the history only when they are changed if a drawing method has been called since the last call of the clearGraphics method. The history consists of:

If you set the backColor property, all graphics are erased. However, if the autoRedraw property is set, the image is repainted using the new backColor.

In general, all graphics instructions should normally be in a paint event unless the autoRedraw property is set to true.

See the startDrawingCapture and stopDrawingCapture methods, which cause the autoRedraw property to be set to true and false, respectively.