Reputation:
I have a code from some article. (picture inner inside the picture outer) The result of the code is when i click the place in the picture outer, the picture inner will show in the place i clicked, but in diagonal place.
It wasnt in the right place i click. I want the picture inner will show in the spot i clicked
picturebox1 name = PictOuter
picturebox2 name = PictInner
Dim pos As String
Dim bos As String
pos = Format(x / PictOuter.Width * 100, "0")
bos = Format(y / PictOuter.Height * 100, "0")
PictInner.Left = PictOuter.Width * pos / 100
PictInner.Top = PictOuter.Height * bos / 100
PictInner.Visible = True
Your information will so helpfull, thanks for your attention
Upvotes: 0
Views: 1023
Reputation: 698
If you simply want the top left corner of the inner box to be where you click, you can use the MouseDown event of the outer PictureBox, which would look like this:
Private Sub PictOuter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
PictInner.Left = X
PictInner.Top = Y
End Sub
You can also choose to perform whatever calculations you'd like on X and Y to center the inner PictureBox however you'd like.
Upvotes: 1