How Do I Make It So That In Run Time The User Can Move The Frame Around?
Printable View
How Do I Make It So That In Run Time The User Can Move The Frame Around?
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
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
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
now it is locked in the top corner, i cant get it back out
right, thats what you asked...
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
when i double click, it does nothing
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
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 :)Quote:
Originally Posted by lavarock09
Quote:
Originally Posted by RhinoBull
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 ???Quote:
Originally Posted by lavarock09
sorry, it drags, but when I release the mouse it doesn't place it
very very thanks |2eM!x
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