I wrote this function to detect whether the mouse pointer is outside of the image:
function TForm1.MouseIsOutsideImage(const X, Y: Integer): Boolean;
begin
Result := (X < 0) or (Y < 0) or (X > ImageEnView1.IEBitmap.Width) or (Y > ImageEnView1.IEBitmap.Height);
end;
I use it in this way:
procedure TForm1.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
var bx := ImageEnView1.XScr2Bmp(X, False);
var by := ImageEnView1.YScr2Bmp(Y, False);
if MouseIsOutsideImage(bx, by) then
begin
DoSomething;
EXIT;
end;
var ThisColor: TColor;
try
ThisColor := TRGB2TColor(ImageEnView1.IEBitmap.Pixels[bx, by]);
except
CodeSite.Send('TForm1.ImageEnView1MouseMove except: bx', bx);
CodeSite.Send('TForm1.ImageEnView1MouseMove except: by', by);
end;
DoSomething(ThisColor);
end;
Is there already a built-in MouseIsOutsideImage (or similar) function in TImageEnView? I didn't find anything in the documentation.