|
-
Dec 26th, 2009, 09:29 PM
#1
Thread Starter
Lively Member
[RESOLVED] Grab Picturebox to move the form.
A new journey, A new problem.
As I downloaded VS2010 Today, there's a new UI, New Code, new problems.
Now I looked for a code that seemed to work for the VS2008, I found the one .Paul made, but it sure didn't work for me.
Is there anyone who managed this on the new 2010? Please tell me.
If there were any confusion what I really wanted, I'll explain.
Mousedown on Picturebox = Move around the form free.
Thanks
-
Dec 26th, 2009, 09:50 PM
#2
Addicted Member
Re: Grab Picturebox to move the form.
Code:
Dim Moveable As Boolean
Dim LastPos As Point
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
Moveable = True
LastPos = Cursor.Position - Me.Location
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If Moveable Then
Me.Location = Cursor.Position - LastPos
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Moveable = False
End Sub
-
Dec 27th, 2009, 05:23 AM
#3
Re: Grab Picturebox to move the form.
If you move to fast with that, then it gets kind of glitchy.
You can use an API to do that instead actually. I know this code is used to move forms, but I found out (by mistake) that you can move objects with it too.
vb.net Code:
Private Declare Sub ReleaseCapture Lib "user32" () Private Declare Sub SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) Private Const WM_NCLBUTTONDOWN As Integer = &HA1 Private Const HTCAPTION As Integer = 2 Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown ReleaseCapture() SendMessage(PictureBox1.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0&) End Sub
-
Dec 28th, 2009, 11:29 AM
#4
Thread Starter
Lively Member
Re: Grab Picturebox to move the form.
Thank you for the replies, it worked very well mal1t1a =)
-
Dec 28th, 2009, 11:30 AM
#5
Re: Grab Picturebox to move the form.
 Originally Posted by macbrutal
Thank you for the replies, it worked very well mal1t1a =)
Also, it's important to note that you shouldn't be using VS 2010 for actual projects as it is still in BETA. You should only be using it for testing out the new features of the IDE and 4.0 framework.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Dec 28th, 2009, 10:03 PM
#6
Addicted Member
Re: Grab Picturebox to move the form.
 Originally Posted by weirddemon
Also, it's important to note that you shouldn't be using VS 2010 for actual projects as it is still in BETA. You should only be using it for testing out the new features of the IDE and 4.0 framework.
This is very true, it's still highly unstable, even when running on Windows 7. It does happen to have "glitches" in it, that cause it to crash. I have not been able to find a way to properly re-create these events, as they happen randomly, which means I can not submit a proper bug report.
Also, you are welcome macbrutal, glad I could help. =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|