DrawMode Property

See Also22JDEY5                 Example1FAHQZC>Low

Applies To

Form14TJ2LN, lineTW530P, picture box31MYIWX, Printer objectCBQUDQ, shape9JZFLA.


Determines the appearance of output from graphics methodsAY3LGR, or the appearance of a shape or line control.


{ [form.][control.]|Printer.}DrawMode[ = mode ]


The DrawMode property settings are:

Setting          Description


1                      Black PenDEFPEN.

2                      Inverse of setting 15 (Merge Pen)NotMergePen.

3                      Combination of the colors common to the background color and the inverse of the penMask Not Pen.

4                      Inverse of setting 13 (Copy Pen)NotCopyPen.

5                      Combination of the colors common to both the pen and the inverse of the displayMaskPenNot.

6                      Inverse of the display colorInvert.

7                      Combination of the colors in the pen and in the display color, but not in bothXorPen.

8                      Inverse of setting 9 (Mask Pen)NotMaskPen.

9                      Combination of the colors common to both the pen and the displayMaskPen.

10                    Inverse of setting 7 (Xor Pen)NotXorPen.

11                    No operationoutput remains unchanged.  In effect, this setting turns drawing offNop.

12                    Combination of the display color and the inverse of the pen colorMergeNotPen.

13                    (Default) Color specified by the ForeColor1W9T6JQ propertyCopyPen.

14                    Combination of the pen color and the inverse of the display colorMergePenNot.

15                    Combination of the pen color and the display colorMergePen.

16                    White Pen.



Use this property to produce visual effects with shape or line controls or when drawing with the graphics methods.  Visual Basic compares each pixel in the draw pattern to the corresponding pixel in the existing background, and then it applies bit-wise17ETARB operations.  For example, setting 7 (Xor Pen) uses the XorLANXOR operator to combine a draw pattern pixel with a background pixel.

The exact effect of a DrawMode setting depends on the way the color of a line drawn at run time combines with colors already on the screen.  Settings 1, 6, 7, 11, 13, and 16 yield perhaps the most predictable results.

Data Type

IntegerDOKXHY (Enumerated)

See Also


DrawStyle Property4PNS0NQ

DrawWidth PropertyMEUSKJ

FillColor PropertyL2TW7M

FillStyle Property2N3S7OE


Programmer's Guide:

Chapter 15, "Creating Graphics for Applications"

DrawMode Property Example

The example enables drawing on a form by dragging the mouse pointer.  Each mouse click sets a different draw mode.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

Sub Form_Load
  DrawWidth = 10                         ' Set DrawWidth.
End Sub

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

Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button Then                         ' While the button is pressed,
    PSet (X, Y)                          ' draw a big point.
  End If
End Sub