Paint Event Example

This example draws a diamond that intersects the midpoint of each side of a form and adjusts automatically as the form is resized. To try this example, paste the code into the Declarations section of a form, and then press F5 and resize the form.

Private Sub Form_Paint ()
   Dim HalfX, HalfY   ' Declare variables.
   HalfX = ScaleLeft + ScaleWidth / 2   ' Set to one-half of width.
   HalfY = ScaleTop + ScaleHeight / 2   ' Set to one-half of height.
   ' Draw a diamond.
   Line (ScaleLeft, HalfY) - (HalfX, ScaleTop)
   Line -(ScaleWidth + ScaleLeft, HalfY)
   Line -(HalfX, ScaleHeight + ScaleTop)
   Line -(ScaleLeft, HalfY)
End Sub

Private Sub Form_Resize
   Refresh
End Sub