Visual Basic Reference

DrawMode Property Example

This example enables drawing on a form by dragging the mouse pointer. Each mouse click sets a different value for the DrawMode property. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Load
   DrawWidth = 10   ' Set DrawWidth.
End Sub
Private Sub Form_Click ()
   Static M As Integer   ' Current DrawMode setting.
   ForeColor = QBColor(Int(Rnd * 15))   ' Choose a color.
   M = ((M + 1) Mod 16) + 1   ' Keep DrawMode 16 or less.
   DrawMode = M   ' Set DrawMode.
End Sub
Private Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
   If Button Then   ' While button is pressed,
      PSet (X, Y)   ' draw a big point.
   End If
End Sub