|
-
Jun 22nd, 2005, 03:51 PM
#1
Thread Starter
Lively Member
Moveable Frames
How Do I Make It So That In Run Time The User Can Move The Frame Around?
-
Jun 22nd, 2005, 03:55 PM
#2
Re: Moveable Frames
VB Code:
Option Explicit
Dim XX As Integer
Dim YY As Integer
Private Sub frame_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
XX = X
YY = Y
End Sub
Private Sub frame_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Frame.Left = Frame.Left - XX + X
Frame.Top = Frame.Top - YY + Y
End If
End Sub
-
Jun 22nd, 2005, 04:04 PM
#3
Thread Starter
Lively Member
Re: Moveable Frames
thanx, i don't know if it is possible, but can i make it so that if it is in a specific place then it locks in, and if not, it is a mini form
-
Jun 22nd, 2005, 04:13 PM
#4
Re: Moveable Frames
sure, like this:
VB Code:
Option Explicit
Dim XX As Integer
Dim YY As Integer
Private Sub frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
XX = X
YY = Y
End Sub
Private Sub frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Frame1.Top <= 0 And Frame1.Left <= 0 Then
Frame1.Top = 0: Frame1.Left = 0
Else
If Button = vbLeftButton Then
Frame1.Left = Frame1.Left - XX + X
Frame1.Top = Frame1.Top - YY + Y
End If
End If
End Sub
-
Jun 22nd, 2005, 04:26 PM
#5
Thread Starter
Lively Member
Re: Moveable Frames
now it is locked in the top corner, i cant get it back out
-
Jun 22nd, 2005, 04:40 PM
#6
Re: Moveable Frames
right, thats what you asked...
-
Jun 22nd, 2005, 05:04 PM
#7
Re: Moveable Frames
How about this ? it simply means that when double clicked the frame will move out of its locked co-ordinates and be moveable again 
VB Code:
Option Explicit
Dim XX As Integer
Dim YY As Integer
Private Sub frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
XX = X
YY = Y
End Sub
Private Sub frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Frame1.Top <= 0 And Frame1.Left <= 0 Then
Frame1.Top = 0: Frame1.Left = 0
Else
If Button = vbLeftButton Then
Frame1.Left = Frame1.Left - XX + X
Frame1.Top = Frame1.Top - YY + Y
End If
End If
End Sub
Private Sub Frame1_DblClick()
If Frame1.Top = 0 And Frame1.Left = 0 Then
Frame1.Top = 1
Frame1.Left = 1
Else:
'do nothing
End If
End Sub
-
Jun 23rd, 2005, 11:12 AM
#8
Thread Starter
Lively Member
Re: Moveable Frames
when i double click, it does nothing
-
Jun 23rd, 2005, 11:38 AM
#9
Re: Moveable Frames
To move control during runtime use DragDrop functionality:
VB Code:
Option Explicit
Dim OffsetX As Integer
Dim OffsetY As Integer
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Set Source.Container = Me
Source.Move X - OffsetX, Y - OffsetY
End Sub
Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
OffsetX = X
OffsetY = Y
Frame1.Drag vbBeginDrag
End Sub
-
Jun 23rd, 2005, 12:16 PM
#10
Re: Moveable Frames
 Originally Posted by lavarock09
when i double click, it does nothing
When its locked at 0,0 on your form double click it, it is then moved to 1,1 (not even noticeable) and can therefore be dragged allover again
-
Jun 25th, 2005, 07:50 AM
#11
Thread Starter
Lively Member
Re: Moveable Frames
 Originally Posted by RhinoBull
To move control during runtime use DragDrop functionality:
VB Code:
Option Explicit
Dim OffsetX As Integer
Dim OffsetY As Integer
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Set Source.Container = Me
Source.Move X - OffsetX, Y - OffsetY
End Sub
Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
OffsetX = X
OffsetY = Y
Frame1.Drag vbBeginDrag
End Sub
After Trying This, it did what i wanted apart from the biggest point, it didn't stay where i wanted it to
-
Jun 25th, 2005, 07:32 PM
#12
Re: Moveable Frames
 Originally Posted by lavarock09
After Trying This, it did what i wanted apart from the biggest point, it didn't stay where i wanted it to
If you can translate it for me maybe I can help you to solve you "problem(s)", eh ???
-
Jul 11th, 2005, 04:35 PM
#13
Thread Starter
Lively Member
Re: Moveable Frames
sorry, it drags, but when I release the mouse it doesn't place it
-
Apr 21st, 2009, 03:35 PM
#14
Junior Member
-
Apr 21st, 2009, 06:31 PM
#15
Re: Moveable Frames
After Trying This, it did what i wanted apart from the biggest point, it didn't stay where i wanted it to.
If you mean you want to stay at a certain position between runs you need to save the left and top properties to a file
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
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
|