[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Graphics' (#lcl)

# TCanvas.CreatePen

Ensures that the Pen for the canvas is valid, configured, and positioned.

## Declaration

Source position: graphics.pp line 1075

`protected procedure TCanvas.CreatePen; virtual;`

## Description

CreatePen is a procedure used to create, configure and position the pen for the canvas.

CreatePen calls SelectObject to get the Handle for the Pen, and saves a copy for local access in the class instance. The MoveTo method is called to position the Pen to the coordinates in the PenPos property. Canvas state flags are updated to indicate that the handle for the Pen is valid.

CreatePen is called when RequiredState is used to check for a valid pen handle.

## See also

TCanvas.Pen |  | The Pen to be used for writing in this canvas.
TCanvas.Handle |  | Handle (or device context) for the drawing surface.
TCanvas.RequiredState |  | Ensures that all handles needed for the canvas are valid.
TPen.Reference |  | A Reference made to this Pen.
TPenMode |  | Represents pen modes used when rendering to a canvas.
TCanvasStates |  | Represents states values for TCanvas.