I'm trying to use a simple code in VB6 to extract the mouse coordinates on a Picturebox using MouseMove event and showing these values in a Textbox, but the results obtained are wrong.
Picturebox (Picture1) is ScaleMode = Pixel, Scaleheight = 249, Scalewidth = 305, ScaleLeft = 0, ScaleTop = 0, Height = 3735, Width = 4574, Borderstyle = None, Appareance = Flat.
When mouse is all over to left, X value is 1 and this is wrong because ScaleLeft = 0.
When mouse is all over to right, X value is 303 and this is wrong because ScaleWidth = 305.
When mouse is at top of picturebox, Y value is 1 and this is wrong because ScaleTop = 0.
When mouse is at bottom of picturebox, Y value is 247 and this is wrong because ScaleHeight = 249.
If I set ScaleLeft and ScaleTop to 0 at Form_Load event, the results are different but not correct...
What I'm doing wrong? there's an API to do that in a better way or more accurate?
What I have tried:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = "X:" & X & "," & "Y:" & Y
End Sub