Quesion about TATImageBox lazarus / 21-General ---------------------------------------------------------------------- stab · 2022-01-12 17:30 Hi, I'm trying learn how to use TATImageBox. Zooming and panning works great. Would like to be able to use MouseDown event, but my program doesn't enter my code even though I've assigned it. Seem to me that the event is somehow disabled. How could one enable it? ---------------------------------------------------------------------- stab · 2022-01-12 22:38 following is excerpt from the lfm-code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if (bitmap2 = nil) or (not chkgColorRects.Checked[0]) then       object ATImageBox1: TATImageBox        Left = 392        Height = 415        Top = 0        Width = 432        HorzScrollBar.Tracking = True      VertScrollBar.Tracking = True        Align = alClient        AutoScroll = False        BorderStyle = bsNone        ClientHeight = 415        ClientWidth = 432        Color = clMedGray        ParentColor = False        PopupMenu = PopupMenu1        TabOrder = 0        OnClick = ATImageBox1Click        OnMouseDown = ATImageBox1MouseDown        OnMouseMove = ATImageBox1MouseMove        OptFitToWindow = True        OptDrag = False      end and following corresponding code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TfrmExtractElevationCurves.ATImageBox1MouseDown(Sender: TObject;  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var  p : pBGRAPixel;begin  if (bitmap2 = nil) or (not chkgColorRects.Checked[0]) then Exit;   p := bitmap2.ScanLine[y];  Inc(p, x);  AddColorRect(p^);  DrawColorRects;end; Have put a breakpoint at:   if (bitmap2 = nil) or (not chkgColorRects.Checked[0]) then which is never hit [Fixed code tags; please read How to use the Forum.] ---------------------------------------------------------------------- jamie · 2022-01-13 02:06 Look here.. https://github.com/Alexey-T/ATViewer/blob/master/Source/ATImageBox.pas Study the source code. The image is overlaying the ImageBox, there for your mouse messages are being sent to the image instead. Maybe you can make some alterations of the source code to fix your needs if you really need to use that.  Me, I would simply piece some code together so I could get better control over it.  TScrollBox and Timage most likely will do as you need. ---------------------------------------------------------------------- stab · 2022-01-13 13:05 Thanks alot, should have thought about that myself. Have to figure out, how to mediate the message. ---------------------------------------------------------------------- AlexTP · 2022-01-13 13:49 It was easy to fix. Fixed. https://github.com/alexey-T/atimagebox- lazarus ---------------------------------------------------------------------- stab · 2022-01-13 19:44 Thanks a lot Alextp, Now it works even though I don't quite understand your changes. What I want to do is to be able to pick pixels from the image, but feel a little unsure where in the image I'm pointing when zoomed in. Could you please explain that to me? ---------------------------------------------------------------------- AlexTP · 2022-01-13 21:11 That may be a useful feature-- some event or prop, so you can detect image pixel under the mouse. Will see it. ---------------------------------------------------------------------- AlexTP · 2022-01-13 21:17 Try to do this: (I didn't test yet) - ATImageBox has the public prop Image: TImage - in the MouseMove event, get X/Y params, and do conversion from screen coords, to Image related coords. Like   P:= ATImageBox1.ClientToScreen(Point(X, Y));   P:= ATImageBox1.Image.ScreenToClient(P); now you have P. Image related coords. Read the zooming value (prop ImageZoom, in percents) and scale P. ---------------------------------------------------------------------- stab · 2022-01-13 22:50 Tried this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TfrmExtractElevationCurves.ATImageBox1MouseMove(Sender: TObject;  Shift: TShiftState; X, Y: Integer);var  Button: TMouseButton;  P : TPoint;  xs, ys, z : single;begin  P := ATImageBox1.ClientToScreen(Point(X, Y));  P:= ATImageBox1.Image.ScreenToClient(P);  xs := P.X; ys := P.Y;  z := 0.01 * ATImageBox1.ImageZoom;  P.X := Round(xs / z);  P.Y := Round(ys / z);  StatusBar1.SimpleText := 'X: ' + IntToStr(x) + ' Y: ' + IntToStr(y) + ' ' +    'Zoom: ' + IntToStr(ATImageBox1.ImageZoom) + ' - ' +    'X: ' + IntToStr(P.X) + ' Y: ' + IntToStr(P.Y);end;   But I didn't get it to work. It seems to be connected to drag coordinates in some way. ---------------------------------------------------------------------- AlexTP · 2022-01-13 23:30 I fixed this, now X/Y must be right, I tested it on a small demo with resized picture. Updated in GH. ---------------------------------------------------------------------- stab · 2022-01-14 14:47 Thanks again, now it's working nicely and keeping coordinates when panning and zooming. Just wonder if you might have forgotten to update the zip-file in GH. I first downloded the zip-file and installed new package but was then back in original functionality. Then I copied the pas-file and after that all worked. /stab ---------------------------------------------------------------------- AlexTP · 2022-01-14 15:02 Zip files are called 'releases',I will update it soon.