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

# TRegion

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

A defined area on a screen or canvas used to render a graphic image or text output.

## Declaration

Source position: graphics.pp line 758

`type TRegion = class(TGraphicsObject)`
`protected`
`procedure SetClipRect();` |  | Sets the value for the ClipRect property.
`function GetClipRect;` |  | Gets the value for the ClipRect property.
`public`
`constructor Create;` |  | Constructor for the class instance.
`destructor Destroy; override;` |  | Destructor for the class instance.
`procedure Assign(); override;` |  | Assign - if Source is another TRegion, copies the dimensions of the clipping rectangle.
`procedure AddRectangle();` |  | Convenience routine to add a rectangle to the region.
`property ClipRect: TRect; [rw]` |  | The clipping rectangle for the region.
`property Handle: HRGN; [rw] deprecated ;` |  | Operating System Handle for the region.
`property Reference: TWSRegionReference; [r]` |  | A Reference to the current Region.
`end;`

## Inheritance

`TRegion` |  | A defined area on a screen or canvas used to render a graphic image or text output.
`TGraphicsObject` |  | Primitive ancestor class, mainly for Delphi compatibility.
`TPersistent`
?
`TObject`

## Description

TRegion is a TGraphicsObject descendant which represents shaped areas that can be drawn, filled, or examined on a screen or canvas. The shaped areas can be one or more rectangles, and can overlap.

Use AddRectangle to create and combine a new rectangular area with the existing areas in the region. Each region has a Handle which identifies the construct. It is modified when a new rectangular area is added to the region.

TRegion is the type used to implement the Region propriety in TCanvas, and passed as an argument to the SetShape method in TWinControl.

Remark: | Some operating systems and widgetsets allow regions to be defined with ellipses, rounded rectangles, and polygons as the sub-regions. TRegion is limited to the rectangle with the area that is the bounding box for a shape. See TLazRegion in LazRegions.pas and TLazCanvas in LazCanvas.pas for alternate implementations that provide these capabilities.