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
Username:
Password:
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  

PeterPanino

860 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?

PeterPanino

860 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;
begin
  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;
end;


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

xequte

38182 Posts

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

Yes, that looks good.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: