|
-
Oct 24th, 2002, 01:29 PM
#1
Thread Starter
Lively Member
-
Oct 25th, 2002, 12:54 AM
#2
Frenzied Member
something like this
in mousedown
firstx = x
firsty = y
in mousemove
object.left = object.left + (x - firstx)
object.top = object.top + (y - firsty)
-
Oct 25th, 2002, 03:21 AM
#3
Thread Starter
Lively Member
uhm...probably not what I mean...
I mean what's the best way to drag the objects over a certain area...
-
Oct 25th, 2002, 04:13 AM
#4
Frenzied Member
yes...
start new project and add a commandbox to it...
then add this code:
VB Code:
Option Explicit
Dim FirstX As Single
Dim FirstY As Single
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
FirstX = X
FirstY = Y
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Command1.Left = Command1.Left + (X - FirstX)
Command1.Top = Command1.Top + (Y - FirstY)
End If
End Sub
-
Oct 25th, 2002, 04:45 AM
#5
Frenzied Member
if you want to lock it inside the form, do this instead:
VB Code:
If Command1.Left < 0 Then Command1.Left = 0
If Command1.Left > Me.ScaleWidth - Command1.Width Then Command1.Left = Me.ScaleWidth - Command1.Width
If Command1.Top < 0 Then Command1.Top = 0
If Command1.Top > Me.ScaleHeight - Command1.Height Then Command1.Top = Me.ScaleHeight - Command1.Height
If Command1.Left > 0 And Command1.Left < Me.ScaleWidth - Command1.Width Then Command1.Left = Command1.Left + (X - FirstX)
If Command1.Top > 0 And Command1.Top < Me.ScaleHeight - Command1.Height Then Command1.Top = Command1.Top + (Y - FirstY)
If Command1.Left <= 0 And X - FirstX >= 0 Then Command1.Left = Command1.Left + (X - FirstX)
If Command1.Left = Me.ScaleWidth - Command1.Width And X - FirstX <= 0 Then Command1.Left = Command1.Left + (X - FirstX)
If Command1.Top = 0 And Y - FirstY >= 0 Then Command1.Top = Command1.Top + (Y - FirstY)
If Command1.Top = Me.ScaleHeight - Command1.Height And Y - FirstY <= 0 Then Command1.Top = Command1.Top + (Y - FirstY)
-
Oct 26th, 2002, 04:50 AM
#6
Thread Starter
Lively Member
UHm...
UHm..you've probably not seen my screenshot?
-
Oct 26th, 2002, 07:51 AM
#7
Frenzied Member
yes i've seen it!
my code makes it possible to click an object and move it around...
wasn't that what you wanted?
-
Oct 26th, 2002, 12:56 PM
#8
Thread Starter
Lively Member
Sorry..!
Yeah sorry...but I misread it.. I thought it said Commandbox...
Is there a way of resizing aswell?? So I can just drag it a little bigger...
-
Oct 26th, 2002, 06:39 PM
#9
Frenzied Member
VB Code:
'change this part
Command1.Left = Command1.Left + (X - FirstX)
Command1.Top = Command1.Top + (Y - FirstY)
'to
Command1.width = Command1.width + (X - FirstX)
Command1.height = Command1.height + (Y - FirstY)
-
Oct 26th, 2002, 07:05 PM
#10
Frenzied Member
try this piece of code:
VB Code:
Option Explicit
Dim FirstX As Single
Dim FirstY As Single
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
FirstX = X
FirstY = Y
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If X <> FirstX Then Command1.Width = Command1.Width + (X - FirstX)
If Y <> FirstY Then Command1.Height = Command1.Height + (Y - FirstY)
Me.Refresh
FirstX = X
FirstY = Y
End If
If Button = 2 Then
If Command1.Left < 0 Then Command1.Left = 0
If Command1.Left > Me.ScaleWidth - Command1.Width Then Command1.Left = Me.ScaleWidth - Command1.Width
If Command1.Top < 0 Then Command1.Top = 0
If Command1.Top > Me.ScaleHeight - Command1.Height Then Command1.Top = Me.ScaleHeight - Command1.Height
If Command1.Left > 0 And Command1.Left < Me.ScaleWidth - Command1.Width Then Command1.Left = Command1.Left + (X - FirstX)
If Command1.Top > 0 And Command1.Top < Me.ScaleHeight - Command1.Height Then Command1.Top = Command1.Top + (Y - FirstY)
If Command1.Left <= 0 And X - FirstX >= 0 Then Command1.Left = Command1.Left + (X - FirstX)
If Command1.Left = Me.ScaleWidth - Command1.Width And X - FirstX <= 0 Then Command1.Left = Command1.Left + (X - FirstX)
If Command1.Top = 0 And Y - FirstY >= 0 Then Command1.Top = Command1.Top + (Y - FirstY)
If Command1.Top = Me.ScaleHeight - Command1.Height And Y - FirstY <= 0 Then Command1.Top = Command1.Top + (Y - FirstY)
End If
End Sub
left mouse button scales, right moves.
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
|