tags:

views:

201

answers:

1

I have a code from some article. (picture inner inside the picture outer) The result of the code is when i was klik the place in the picture outer, the picture inner will show in the place i was klik, but in diagonal place.

It wasnt in the right place i was klik. I want the picture inner will show in the spot i was klik

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

A: 

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.

Ryan