i was improve my knowledge about picturebox in vb 6,
i just want to know can i
inside an image into picturebox when i was
klik the part in the picturebox, and the image will
show in the spot i was klik in the picturebox
Printable View
i was improve my knowledge about picturebox in vb 6,
i just want to know can i
inside an image into picturebox when i was
klik the part in the picturebox, and the image will
show in the spot i was klik in the picturebox
Moved to VB6. The FAQ forum isn't for asking questions.
hey randichan
pls be more specific regarding asking questions
what i understand from your post is u want to know where user has clicked in picturebox ??
so just put picturebox on form from toolbox and put this code
vb Code:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Debug.Print "X:" & X, "Y:" & Y End Sub
this will show ur position in debug window
it debug window is not shown then hit ctrl+g to visible it
or else pls explain with more details
Thanks for your reply, sorry about uncomplete question,
i have a code from vb forum. 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
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
I've got no idea why you are doing all of that work - you do a calculation, store the result to a formatted String (thus lose precision), and then undo the calculation.
Why not assign the values directly? eg:
The X and Y parameters are in the scalemode of picOuter, and so are .Left and .Top of picInner (as it is inside picOuter), so this sets the top-left of picInner to wherever you click.Code:Private Sub picOuter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
picInner.Left = X
picInner.Top = Y
End Sub
If you want the centre of picInner to be where you click, just offset it by that amount, eg:
Code:Private Sub picOuter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
picInner.Left = X - (picInner.Width / 2)
picInner.Top = Y - (picInner.Height / 2)
End Sub
>klik future reference "click"
change both picture boxes scalemode to vbpixels in code or through properties. Use the mouse move event of the outer picture box to know where you are and and which mouse button is push and where. From there it should be easy to accomplish what you want.
Good Luck
Duplicate threads merged - please post each question (or variation of it) only once.