ImageEn, unit imageenview




property OnDrawLayerBox: TIEDrawLayerBoxEvent;


Occurs when a layer box must be painted (LayersDrawBox must be enabled). If you handle this event the default behavior is disabled.
ABitmap is the destination bitmap and layer is the layer index that we are drawing.
Use Layers[].ClientAreaBox rectangle to get actual rectangle coordinates.

See the LayerEditing\Layers demo for more details.

Note: You can also use SetLayersBoxStyle to customize the layer box style

ImageEnView Paint Events

The main paint events of TImageEnView are OnDrawBackBuffer which occurs when the back buffer is painted and OnDrawCanvas which occurs every time the canvas is painted. Generally OnDrawBackBuffer is used for better performance, because the back buffer painting only occurs after the content is updated. If you need constant custom drawing (e.g. to draw a marker at the current cursor position) then use OnDrawCanvas.

In layer applications, OnBeforeDrawLayer and OnDrawLayer will occur while painting each individual layer. Use these methods if you need easy custom drawing upon each individual layer (e.g. a layer title). Generally OnBeforeDrawLayer is best, unless you need to paint to the whole image (i.e. outside the area of the layer).

Other drawing events:
- OnDrawBackground occurs when the background (area behind the image is painted) is painted to allow custom background styling
- OnDrawLayerBox occurs when the box around a layer is painted to allow custom styling of the box
- OnDrawLayerGrip occurs when the grips of the selected layer are drawn to allow custom grip styling
- OnTransitionPaint occurs while transitioning from one image to the next
- OnPaint notifies whenever there is a paint event. It is not used for custom drawing
- OnDrawPolygon notifies whenever a point of a polygonal selection is drawn


procedure Tfmain.ImageEnView1DrawLayerBox(Sender: TObject; ACanvas: TCanvas; LayerIndex: Integer);
  // a green line
  with ACanvas do
    Pen.Style := psSolid;
    Pen.Width := 2;
    Pen.mode := pmCopy;
    Pen.Color := clGreen;
    Brush.Style := bsClear;
    with ImageEnView1.Layers[LayerIndex].ClientAreaBox do
      Rectangle(Left-1, Top-1, Right+1, Bottom+1);

// Use an empty OnDrawLayerBox to prevent a selection box from being drawn around the current layer
procedure Tfmain.ImageEnView1DrawLayerBox(Sender: TObject; ACanvas: TCanvas; LayerIndex: Integer);

Compatibility Information

Prior to v8.0.0, OnDrawLayerBox used a TBitmap rather than a TCanvas. You may need to remove the existing event and add the event handler again.