OnPaint Event (AForm)

Occurs when part or all of an object is exposed after being moved or enlarged, or after a window that was covering the object has been moved.

Syntax

Object.OnPaint()

The OnPaint event syntax has the following parts:

 

Name

Type

Description

Object

AForm

AForm object

Comments

An OnPaint event procedure is useful if you have output from graphics methods in your code. With a Paint procedure, you can ensure that such output is repainted when necessary.

The OnPaint event is invoked when the Refresh method is used. If the AutoRedraw property is set to True, repainting or redrawing is automatic, so no OnPaint events are necessary.

If the ClipControls property is set to False, graphics methods in the OnPaint event procedure affect only newly exposed areas of the form; otherwise, the graphics methods repaint all areas of the form not covered by controls.

Using a Refresh method in a OnResize event procedure forces repainting of the entire object every time a user resizes the form.

Note: Using an OnPaint event procedure for certain tasks can cause a cascading event. In general, avoid using an OnPaint event procedure to do the following:

An OnResize event procedure may be more appropriate for some of these tasks.

Example

The following example draws an diagonal line across the form.

Procedure MyForm.OnPaint(): Void Public

{

Line(0, 0, frm1.Width, frm1.Height)

}

Applies to

AForm

See Also

AutoRedraw, BackColor, ClipControls, OnResize, Refresh