ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder


ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TImageEnView: IsMouseWithinImageBoundaries?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  


719 Posts

Posted - Feb 27 2023 :  04:46:05  Show Profile  Reply
In ImageEnView.OnMouseMove, I need to detect whether the mouse pointer is inside or outside the image boundaries. It seems there is no explicit function to detect this. How can this be done?


719 Posts

Posted - Feb 27 2023 :  05:16:49  Show Profile  Reply
I just now wrote this function that can be called from OnMouseMove:

function TformMain.IsMouseWithinImageBoundaries(const X, Y: Integer): Boolean;
  Result := False;

  var bx := ImageEnView1.XScr2Bmp(X, False);
  var by := ImageEnView1.YScr2Bmp(Y, False);

  if (bx >= 0) and
     (bx < ImageEnView1.IEBitmap.Width) and
     (by >= 0) and
     (by < ImageEnView1.IEBitmap.Height)
  then Result := True;

I think it should be declared as inline?

Is this correct? Is there a better/shorter way to detect this?
Go to Top of Page


37560 Posts

Posted - Feb 27 2023 :  20:11:33  Show Profile  Reply
Hi Peter

Yes, that looks good.

Xequte Software
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: