|
-
Oct 10th, 2001, 12:49 AM
#1
Thread Starter
Hyperactive Member
Move form on MouseDown instead of 'release'
Hi,
I want to know how a form can be moved on the MouseDown event, like you can move the form while dragging it, instead of 'finish' dragging it. Just like Winamp. Pls tell me
thanx
-
Oct 10th, 2001, 07:29 AM
#2
Good Ol' Platypus
Try making a boolean value (myBool), and four long values (nX, nY, cX, cY) in the General Declarations. On the MouseDown, set this boolean to true, and nX and nY values to the X and Y. Then, in the mousemove, make cX equal to nX - X, and cY equal to nY - Y. Then set nX to X, and nY to Y. On the MouseUp, set the boolean to false. Here's a bit of code explaining this:
VB Code:
[COLOR=indigo]Form1.frm[/COLOR]
Option Explicit
Dim myBool
Dim nX As Long
Dim nY As Long
Dim cX As Long
Dim cY As Long
Private Sub Form_MouseDown(...)
myBool = True
nX = X
nY = Y
End Sub
Private Sub Form_MouseMove(...)
cX = X - nX
cY = Y - nY
End Sub
Private Sub Form_MouseUp(...)
myBool = False
End Sub
After this, you can do basically whatever you want with this code, you could set the form's position, or make a selection rectangle. Lots of things can be accomplished!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 10th, 2001, 07:39 AM
#3
Thread Starter
Hyperactive Member
what does the X and Y stand for and wat ar variables like nY for?
-
Oct 10th, 2001, 03:14 PM
#4
Good Ol' Platypus
If you clicked, and held and moved your mouse, nX and nY would be the amount it was moved every time. X and Y are the positions of your mouse from the top of the form [or control] and from the left of the form [or control], respectively.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 10th, 2001, 08:13 PM
#5
Thread Starter
Hyperactive Member
i get what u mean but i still can't get it to work
poor me..
-
Oct 10th, 2001, 09:27 PM
#6
Good Ol' Platypus
Well the code in itself does nothing! To add functionality... add Me.Move cX, cY after all the other code in the mousemove section.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 10th, 2001, 10:54 PM
#7
Thread Starter
Hyperactive Member
oh it worked(somehow).....but it turned out funny, all flickering and leaving traces until i release and move my mouse away?
-
Oct 11th, 2001, 07:25 AM
#8
Good Ol' Platypus
Yeah, it tends to do that. There is a non-buggy windowless move somewhere on the 'net, try to find that.
Cheers from Canada
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 11th, 2001, 09:21 AM
#9
PowerPoster
Sas you should know I have that demo 
However, I corrected you that code, try this:
Code:
'Variables
Dim X2 As Long
Dim Y2 As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Store mouse position
X2 = X
Y2 = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Move form if neccessary
If Button = 1 Then: Me.Move Me.Left + (X - X2), Me.Top + (Y - Y2)
End Sub
'Code improved by vBulletin Tool 2.0
-
Oct 11th, 2001, 03:15 PM
#10
Good Ol' Platypus
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 12th, 2001, 01:08 AM
#11
Thread Starter
Hyperactive Member
-
Oct 15th, 2001, 06:25 AM
#12
Frenzied Member
hmmmm
there is a setting in windows to change that...
it makes the form move while you drag it...
-
Oct 15th, 2001, 06:28 AM
#13
PowerPoster
*sigh* thats not what he meant
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
|