Hello,
I am finding it hard to describe the problem properly but let me try....
I am trying to draw a border in ImageEnView. With help from Bill I managed to draw a border by placing code in DrawBackBuffer event.
But the problem is that the border drawn changes size when the view changes. Meaning if the zoom of ImageEnView is changed the border does not stay as it is. Instead it is always drawn in the visible part of ImageEnView.
How to draw a border around ImageEnView leaving 25 pixels as margin which will stay the same even when user zooms in or out?
For better understanding here are a few screen shots.


Here is the code that I am using:
procedure TForm1.ImageEnVect1DrawBackBuffer(Sender: TObject);
{ Automatically draw the grid in the background, eliminates the need to use objects and is much faster and much better
than using objects }
var
ix1: Integer;
iy1: Integer;
ix2: Integer;
iy2: Integer;
begin
{ Get the corners of the bitmap }
ix1 := ImageEnVect1.OffsetX;
iy1 := ImageEnVect1.OffsetY;
ix2 := ImageEnVect1.ExtentX;
iy2 := ImageEnVect1.ExtentY;
{ Draw a blue rectangle around the bitmap }
ImageEnVect1.BackBuffer.Canvas.Pen.Width := 1;
ImageEnVect1.BackBuffer.Canvas.Pen.Color := clGreen;
ImageEnVect1.BackBuffer.Canvas.Pen.Style := psSolid;
ImageEnVect1.BackBuffer.Canvas.Brush.Style := bsClear;
ImageEnVect1.BackBuffer.Canvas.Rectangle(ix1 + 25, iy1 + 25, ix1 + ix2 - 25, iy1 + iy2 - 25);
{ Draw crosshairs }
ImageEnVect1.BackBuffer.Canvas.Pen.Color := clBlack;
ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1 + ix2 div 2, iy1);
ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + ix2 div 2, iy1 + iy2);
ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1, iy1 + iy2 div 2);
ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + ix2, iy1 + iy2 div 2);
{Draw 4 Simple Lines}
ImageEnVect1.BackBuffer.Canvas.Pen.Color := clBlue;
ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1 + ix2 div 4 + 12, iy1);
ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + ix2 div 4 + 12, iy1 + iy2);
ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1 + (ix2 div 4) * 3 - 12, iy1);
ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + (ix2 div 4) * 3 - 12, iy1 + iy2);
ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1, iy1 + iy2 div 4 + 12);
ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + ix2, iy1 + iy2 div 4 + 12);
ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1, iy1 + (iy2 div 4) * 3 - 12);
ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + ix2, iy1 + (iy2 div 4) * 3 - 12);
end;
TIA
Yogi Yang