The best flicker-free way probably would be to draw the crosshair in the OnBackBuffer event. I use it all the time to draw an ellipse for brush painting, so it probably should work for a crosshair.
procedure TForm1.ImageEnView1DrawBackBuffer(Sender: TObject);
{ Draw an ellipse in the DrawBackBuffer Event - refresh with Update. }
var
i: Double;
z: Double;
mx1: Double;
my1: Double;
lx1: Double;
ly1: Double;
x1, y1, x2, y2: Integer;
bx, by: Integer;
begin
bx := ImageEnView1.Layers[ImageEnView1.LayersCurrent].ConvXScr2Bmp
(ABackBufferX);
by := ImageEnView1.Layers[ImageEnView1.LayersCurrent].ConvYScr2Bmp
(ABackBufferY);
if (bx >= 0) and (bx <= ImageEnView1.IEBitmap.Width - 1) and (by >= 0) and
(by <= ImageEnView1.IEBitmap.Height - 1) then
with ImageEnView1.BackBuffer.Canvas do
begin
i := BrushPaint1.BrushSize / 2;
Pen.Mode := pmNOTXOR; // pmCopy;
Brush.Style := bsClear;
z := ImageEnView1.Zoom / 100;
mx1 := ABackBufferX; ( integer set in OnMouseMoveEvent }
my1 := ABackBufferY; ( integer set in OnMouseMoveEvent }
lx1 := ABackBufferX;
ly1 := ABackBufferY;
x1 := Round(mx1 - i * z);
y1 := Round(my1 - i * z);
x2 := Round(lx1 + i * z);
y2 := Round(ly1 + i * z);
{if ImageEnView1.Bitmap.Width > 64 then
Ellipse(x1, y1, x2, y2)
else
Rectangle(x1, y1, x2, y2);}
// Draw crosshairs here
Pen.Style := psDash;
Pen.Width := 2;
MoveTo(x1, y1);
LineTo(x1 + 5, y1 + 5);
end;
end;
end;
The on ImageEnView.OnBackBuffer event is called whenever ImageEnView.Update is called... such as in OnMouseMove.
William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom Commercial ImageEn Development