I am working with an image, and, for the moment, i need to know the position (coordinates) of the cursor in the image.
To do that, i have a Timage, and a label.
In the Timage, i added this code to the events 'OnmouseMove' and 'Onmouse leave'
// Procedure to show the (relative) coordinates of the cursor on the image
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Label1.Caption := Format('%d,%d', [X, Y]); // way 1
//Label1.caption:= '('+IntToStr(X)+','+IntToStr(Y)+')'; // way 2
end;
// Procedure to clear the label when the mouse leave the image
procedure TForm1.Image1MouseLeave(Sender: TObject);
begin
Label1.caption := '';
end;
As you can see, in 'OnMouseMove' event i tried two different ways to show the coordinates in the label caption. However, although both ways 'work' somehow, the result is the same in boths, and here is the problem: The coordinates are only updated once the mouse stop on the image, but coordinates are not updated meanwhile the cursor is under movement on the image.
I googled a lot and the procedure seems to be ok, but i do not know why i have these behaviour.
Any idea about what i am doing wrong? Thanks!