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

# TCanvas.Handle

Handle (or device context) for the drawing surface.

## Declaration

Source position: graphics.pp line 1170

`public property TCanvas.Handle : HDC read GetHandle write SetHandle;`

## Description

Handle is a HDC property that provides the device context for the drawing surface. A valid Handle is required for nearly all operations performed on the canvas.

Read access calls RequiredState, and allocates a Handle by calling CreateHandle if one does not already exist. An EInvalidGraphicOperation exception may be raised in the method if a valid handle cannot be acquired.

Remark: | CreateHandle is an empty implementation in TCanvas, and is overridden in descendent classes to return a handle for an image format or output device. See TBitmapCanvas, TControlCanvas, TPrinterCanvas, et. al.

Setting a new value for Handle causes saved Brush, Pen, and Font handles to be reset to their default values. The AntialiasingMode for the canvas is also re-applied.

## See also

TCanvas.RequiredState |  | Ensures that all handles needed for the canvas are valid.
TCanvas.CreateHandle |  | Creates a new Handle for the Canvas.
TCanvas.DeselectHandles |  | Deselects all sub-handles in the current device context.
TCanvas.Brush |  | The Brush used to paint on the Canvas.
TCanvas.Pen |  | The Pen to be used for writing in this canvas.
TCanvas.Font |  | Contains the Font used to render text on the drawing surface.
EInvalidGraphicOperation |  | EInvalidGraphicOperation - exception handler for invalid graphic operation.