Vcl.Graphics.TCanvas.Handle

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property Handle: HDC read GetHandle write SetHandle;

C++

__property HDC Handle = {read=GetHandle, write=SetHandle, nodefault};

Properties

Type Visibility Source Unit Parent
property public
Vcl.Graphics.pas
Vcl.Graphics.hpp
Vcl.Graphics TCanvas

Description

Specifies the handle for this canvas.

The Handle property specifies the Windows GDI handle to the device context for this canvas.

Set Handle to the HDC for the device context the canvas must draw into. When a windowed control responds to a Windows paint message, the HDC for drawing is passed in to the PaintWindow method. In other cases, an HDC can be obtained for a window by calling the GetDeviceContext method of a control. Additionally, Windows provides API calls to obtain an HDC for a printer or for a memory image.

Read the Handle property to supplement the drawing services provided by the TCanvas object with API calls that require a handle to a device context. Most of the Windows GDI calls require an HDC.

TCanvas does not own the HDC. Applications must create an HDC and set the Handle property. Applications must release the HDC when the canvas no longer needs it. Setting the Handle property of a canvas that already has a valid HDC will not automatically release the initial HDC.

Note: Some descendants of TCanvas, such as TControlCanvas, do own the HDC. Do not set the Handle property for these objects. They fetch and free their own Handle.

See Also

Code Examples