SRL Archive - C#/Visual Basic Help and Tutorials

help making user control :[ please


g0tp0t

2010-05-09 17:59:57

is this written correctly?when i run, the pholder moves down 1 pixel seemingly randomly but at an average speed of like 6 pixels per 2 seconds. also, when i click the mouse(not releaseing it, basicly calling mousedown event) the pholder moves to point 0,0. i dont think i asked it to do that :\ :]

EDIT: this is supposed to allow me to drag the picture box around during runtime.
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, ToolStripComboBox1.MouseDown, ToolStripMenuItem1.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
If Downn Then PHolder.Location = New Point((PHolder.Location.X + MousePosition.X - M_Point.X) / 2, (PHolder.Location.Y + MousePosition.Y - M_Point.Y) / 2)
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

EDIT: PHolder is a PictureBox

mikevskater

2010-05-11 01:42:43

so if i read this corectly, you basicly want to make the picturebox move to the mouse?

cycrosism

2010-05-11 08:00:37

[Offtopic] How are you not a junior member? You have been here for ~ 2 months and have 376 posts? [/Offtopic]

Dgby714

2010-05-11 08:08:13

From: cycrosism
[Offtopic] How are you not a junior member? You have been here for ~ 2 months and have 376 posts? [/Offtopic]


They have changed things >.>

g0tp0t

2010-05-11 11:05:23

No, i want to be able to drag the picturebox during runtime. :P. didnt think this thread would ever get going. lol

i used to be spoonbeater8p(horrible name, it was a joke :P) who was here for 3 years over 10 posts and no junior mem. idc. junior mem gives no better benefits. and i now need to be here for 6 months and over 800 posts or something for junior mem :\

lmao. i like the new rule

less leachers. i dont like the reg users seeing the junior mem scripts though.

and to become junior mem you should have to prove you wanna be part of the community. like submit a few scripts or something. nothing like high standards of mem scripts though :P.

i LOVE SRL. <3

mikevskater

2010-05-11 15:44:15

From: 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


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

g0tp0t

2010-05-12 07:43:58

omg. should have thought of that. tyvm ^_^

mikevskater

2010-05-12 11:27:14

From: g0tp0t
omg. should have thought of that. tyvm ^_^


NP lol, at first i was like why isnt this working…?!? it should be =[

Then when i set the labels to its positon i was like WOW!

g0tp0t

2010-05-12 13:51:32

lol. i ran it. 1 problem but i think i can fix. it doesnt drag. instead it moves to were your mouse is if the left button is pressed. it also moves to only the center lol. this will be a control i will first use to make a runsecape map. im going to add a function wich creates labels at certain positions in dif zooms. with math :P

mikevskater

2010-05-13 00:07:09

From: g0tp0t
lol. i ran it. 1 problem but i think i can fix. it doesnt drag. instead it moves to were your mouse is if the left button is pressed. it also moves to only the center lol. this will be a control i will first use to make a runsecape map. im going to add a function wich creates labels at certain positions in dif zooms. with math :P


ohh yeah, i didnt know the exact use of it so i made it move to the center ;P lol

g0tp0t

2010-05-13 12:13:21

lol. yup. the zoom isnt going to have preset levels either. i will also add a few functions like zoom to points wich would zoom so all points given can be seen within a 20 pixel margin of the end of the veiw. also it will have searching once i have gotten all the locations of each symbol.l. i will do that with scar

mikevskater

2010-05-13 23:12:07

sweet, cant wait to see when its done