I am trying to make userform that can show chart coordinates when i hover mouse over the chart
Here are some explanations:
-I have userform named "userform1" that has image named "image1"
-EDIT : the same userform has height (467.25),left (0), top(0),width(876), startupposition = 1-CenterOwner
-the same image has height (426),left (6), top(6),width(702)
-the same userform have 2 label named "label_x" and "label_y"
-the image will import chart with x value of (0 to 100) and y value of (100 to 200)
-the code below is to show coordinates of image1 when I hover mouse over
Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim coor As POINTAPI
GetCursorPos coor
UserForm1.Label_x.caption = " X : " & coor.X
UserForm1.Label_y.caption = " Y : " & coor.Y
End Sub
-here are the demonstration of current code the x and y value that shown are wrong
i have tried to make a manual calibration by asking user to click the top right and bottom left corner of the chart to calibrate the coordinates correctly
But i dont think it will be comfortable for user to do that
Is there a way to automatically calibrate chart coordinates? I think it have to do with userform position, image position, and screen resolution, but i do not know how
Thanks
I think i have figure it out how to do it it is still semi automatic method, I hope it can be a future reference for others
I still hope for other method
here how it is done
-First we need to get the user screen resolution
-second, we need to get 2 point of the chart manually, I take bottom left and top right of the chart, then use this calculation and sub below