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.
Object.OnPaint()
The OnPaint event syntax has the following parts:
Name |
Type |
Description |
Object |
AForm |
AForm object |
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:
Move or size a form or control.
Change any variables that affect size or appearance, such as setting an object's BackColor property.
Invoke a Refresh method.
An OnResize event procedure may be more appropriate for some of these tasks.
The following example draws an diagonal line across the form.
Procedure MyForm.OnPaint(): Void Public
{
Line(0, 0, frm1.Width, frm1.Height)
}
AutoRedraw, BackColor, ClipControls, OnResize, Refresh