AutoRedraw, Image Properties

Purpose

AutoRedraw creates a persistent memory bitmap and sets the output from graphic commands to the bitmap. The Image property returns the bitmap as Picture object.

Syntax

[Form.]AutoRedraw [= iexp]

Set pic = Form.Image

pic:Picture Object

Description

Enables automatic repainting of a Form object. Graphics and text drawn using GFA-BASIC 32 commands are written to both the screen and to an image stored in memory. Windows API functions should use the special memory device context hDC2 handle to draw on the memory bitmap.

AutoRedraw = 0 disable
AutoRedraw = 1 device dependent bitmap
AutoRedraw = 2 device independent bitmap (DIB)

In contrast with VB, the Form object does receive Paint events when AutoRedraw is enabled. The client area is repainted when necessary using the image stored in memory, but additional drawing can take place in the Paint event sub. The graphic output in the Paint event is, of course, drawn in the AutoRedraw bitmap as well.

The AutoRedraw image can be obtained using the Image property. The Image and Picture properties are normally used when assigning values to other properties, when saving with the SavePicture statement, or when placing something on the Clipboard. You can't assign these to a temporary variable, other than the Picture data type. There is no image when AutoRedraw = 0.

Example

OpenW 1

AutoRedraw = 2   // a DIB

PBox 10, 10, _X - 20, _Y - 40

Print

Print HimetsToPixelX( Me.Image.Width )

Print HimetsToPixelY( Me.Image.Height )

Do

Sleep

Until IsNothing(Me)

 

Sub Win_1_Paint

Text 0, 0, "Paint"

EndSub

Remarks

AutoRedraw is a property of the Form object type. Used without a Form object the current active form (Me) is affected.

If AutoRedraw = 1 or 2, there exist a _DC2, a memory device context. If AutoRedraw = 0 _DC2 = Null.

Note AutoRedraw does not have a Boolean type, you should not test for AutoRedraw == True. True represents -1 and not 1 or 2, which are valid values.

See Also

Form, Picture, _DC2

{Created by Sjouke Hamstra; Last updated: 26/09/2014 by James Gaite}