Canvas Cursor Position

Hello to all, I am new to this forum. Using System.MouseX and System.MouseY will give pixel x y location
based from window form. Is there a command to get x y pixel from Canvas datum instead from Window form.

What do you really want to do ?

The Canvas Left / Right position or a “Cursor” position ?
In the first case: use .Left and .Top.
In the latter case, you have to compute the text length and add the start text x value…

I had a Map placed in the canvas at one corner of the screen. I would like to plot Lat and long on the map by moving the cursor and calculate using the x y pixel differential. It works provided I subtracted the differential pixel from the screen edge to the Canvas edge.
But I think it will not give the right answer if I run the program in another computer with different screen size.
Basically, I am trying to get cursor position x y in the canvas area.

OK, you mean the Mouse Cursor (the arrow icon, not the text cursor).

First idea for debug:

Add a MouseMove Event to your Canvas and the code:

Sub MouseMove(X As Integer, Y As Integer) TF_Info.Text = "x,y: " + Str(X) + "," + Str(Y) End Sub

Also add a TextField and name it TF_Info.

Move the Mouse above the Canvas and enjoy the x,y Mouse locations in the TF_Info TextField.

Now you can continue to program (I hope). When your tests are done, you can remove the TextField and the MouseMove Event Code (above) that you use as a debugging way.

Great, It works. Thanks a lot. I don’t know how I miss that after long hours of search in the net.

Better read the docs… :wink:
It escapes me too until I found it.