Originally Posted by
g0tp0t
No, i want to be able to drag the picturebox during runtime. :P. didnt think this thread would ever get going. lol
Ill throw your code into vb, and see what it does, and see what the problem is h/o
Here you go, i belive i fixed the prob, your calculations were all off. it was going off windows mouse position, not the forms mouse position... lol
Code:
Public Class PBox
Property Img() As String
Set(ByVal value As String)
PHolder.ImageLocation = Img
End Set
Get
Img = PHolder.ImageLocation
End Get
End Property
Private Sub PHolder_Loaded(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles PHolder.LoadProgressChanged
'PHolder.ImageLocation = "C:\Users\josh\Pictures\cgjvbmn.png"
End Sub
Public M_Point, ploc, pmove As Point
Public Downn As Boolean = False
Public upp As Boolean = False
Private Sub Mouse_Down(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PHolder.MouseDown, MyBase.MouseDown
M_Point = MousePosition
Downn = True
Dim senderer As Object = PHolder
Dim ee As System.EventArgs
ee = EventArgs.Empty
Call PBox_Move(senderer, e)
End Sub
Private Sub PBox_Move(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PHolder.MouseMove
Dim x, y As Integer
Label4.Text = Me.Location.X & " , " & Me.Location.Y
x = MousePosition.X - Me.Location.X
y = MousePosition.Y - Me.Location.Y
Label4.Text = Me.Text & " | " & x & " , " & y
If Downn Then PHolder.Location = New Point(x - (PHolder.Width / 2) - 10, y - (PHolder.Height / 2) - 30)
Label1.Text = MousePosition.X
Label2.Text = MousePosition.Y
Label3.Text = PHolder.Location.X & " , " & PHolder.Location.Y
End Sub
Private Sub PHolder_MouseUp(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PHolder.MouseUp
Downn = False
End Sub
End Class
All those labels were for debugging purposes