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
 Problem with mouse coords and rulers
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

MrDeveloper

Switzerland
17 Posts

Posted - Sep 27 2021 :  11:02:31  Show Profile  Reply
Hello

I noticed something in the following experiment:

As an example, exactly at the mouse cursor position inside the TImageEnView I want to create a ellipse shape layer (fix 50px size for this example) via the OnMouseDown event. Do you have any idea what would be a better event for this task?

I have chosen the center of the circle for the origin. But if, for example, the ruler is displayed on the left, the X coordinates from the event are not correct. They have exactly the offset from the width of the ruler.

Of course this can be worked around as seen below, but I think if depending on how the vert/horz rulers are visible, the X and Y coordinates should already be passed to the correct mouse positions or not?

The simple code snippet below only works correct for view 100% of course. So how we can get the correct mouse position "inside" the control canvas area (depening on zoom, rulers etc.)? So that the circle can be always placed correctly on the center point of the mouse cursor position.


procedure TMainForm.ImageEnViewMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  ImageEnView.LayersAddEx(ielkShape,
    (X-ImageEnView.RulerParams.VertWidth) - 25,
     Y - 25,
     50,
     50);
end;


Thanks a lot!

xequte

39051 Posts

Posted - Sep 27 2021 :  20:22:35  Show Profile  Reply
Hi

Please use XScr2Bmp/YScr2Bmp to convert screen values (X,Y or MouseDown) to bitmap values:

https://www.imageen.com/help/TImageEnView.XScr2Bmp.html
https://www.imageen.com/help/TImageEnView.YScr2Bmp.html

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