Results 1 to 15 of 15

Thread: Moveable Frames

  1. #1

    Thread Starter
    Lively Member lavarock09's Avatar
    Join Date
    Jun 2005
    Posts
    124

    Moveable Frames

    How Do I Make It So That In Run Time The User Can Move The Frame Around?

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Moveable Frames

    VB Code:
    1. Option Explicit
    2.  
    3. Dim XX As Integer
    4. Dim YY As Integer
    5.  
    6. Private Sub frame_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    7.     XX = X
    8.     YY = Y
    9. End Sub
    10.  
    11. Private Sub frame_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    12.     If Button = vbLeftButton Then
    13.         Frame.Left = Frame.Left - XX + X
    14.         Frame.Top = Frame.Top - YY + Y
    15.     End If
    16. End Sub

  3. #3

    Thread Starter
    Lively Member lavarock09's Avatar
    Join Date
    Jun 2005
    Posts
    124

    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

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Moveable Frames

    sure, like this:

    VB Code:
    1. Option Explicit
    2. Dim XX As Integer
    3. Dim YY As Integer
    4.  
    5. Private Sub frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    6.     XX = X
    7.     YY = Y
    8. End Sub
    9.  
    10. Private Sub frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    11.     If Frame1.Top <= 0 And Frame1.Left <= 0 Then
    12.         Frame1.Top = 0: Frame1.Left = 0
    13.             Else
    14.     If Button = vbLeftButton Then
    15.         Frame1.Left = Frame1.Left - XX + X
    16.         Frame1.Top = Frame1.Top - YY + Y
    17.     End If
    18.    End If
    19. End Sub

  5. #5

    Thread Starter
    Lively Member lavarock09's Avatar
    Join Date
    Jun 2005
    Posts
    124

    Re: Moveable Frames

    now it is locked in the top corner, i cant get it back out

  6. #6
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Moveable Frames

    right, thats what you asked...

  7. #7
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    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:
    1. Option Explicit
    2. Dim XX As Integer
    3. Dim YY As Integer
    4.  
    5. Private Sub frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    6.     XX = X
    7.     YY = Y
    8. End Sub
    9.  
    10. Private Sub frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    11.     If Frame1.Top <= 0 And Frame1.Left <= 0 Then
    12.         Frame1.Top = 0: Frame1.Left = 0
    13.             Else
    14.     If Button = vbLeftButton Then
    15.         Frame1.Left = Frame1.Left - XX + X
    16.         Frame1.Top = Frame1.Top - YY + Y
    17.     End If
    18.    End If
    19. End Sub
    20.  
    21. Private Sub Frame1_DblClick()
    22. If Frame1.Top = 0 And Frame1.Left = 0 Then
    23. Frame1.Top = 1
    24. Frame1.Left = 1
    25. Else:
    26. 'do nothing
    27. End If
    28. End Sub
    Zeegnahtuer?

  8. #8

    Thread Starter
    Lively Member lavarock09's Avatar
    Join Date
    Jun 2005
    Posts
    124

    Re: Moveable Frames

    when i double click, it does nothing

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Moveable Frames

    To move control during runtime use DragDrop functionality:
    VB Code:
    1. Option Explicit
    2.  
    3. Dim OffsetX As Integer
    4. Dim OffsetY As Integer
    5.  
    6. Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
    7.     Set Source.Container = Me
    8.     Source.Move X - OffsetX, Y - OffsetY
    9. End Sub
    10.  
    11. Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    12.     OffsetX = X
    13.     OffsetY = Y
    14.     Frame1.Drag vbBeginDrag
    15. End Sub

  10. #10
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Moveable Frames

    Quote 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
    Zeegnahtuer?

  11. #11

    Thread Starter
    Lively Member lavarock09's Avatar
    Join Date
    Jun 2005
    Posts
    124

    Re: Moveable Frames

    Quote Originally Posted by RhinoBull
    To move control during runtime use DragDrop functionality:
    VB Code:
    1. Option Explicit
    2.  
    3. Dim OffsetX As Integer
    4. Dim OffsetY As Integer
    5.  
    6. Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
    7.     Set Source.Container = Me
    8.     Source.Move X - OffsetX, Y - OffsetY
    9. End Sub
    10.  
    11. Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    12.     OffsetX = X
    13.     OffsetY = Y
    14.     Frame1.Drag vbBeginDrag
    15. End Sub

    After Trying This, it did what i wanted apart from the biggest point, it didn't stay where i wanted it to

  12. #12
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Moveable Frames

    Quote 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 ???

  13. #13

    Thread Starter
    Lively Member lavarock09's Avatar
    Join Date
    Jun 2005
    Posts
    124

    Re: Moveable Frames

    sorry, it drags, but when I release the mouse it doesn't place it

  14. #14
    Junior Member
    Join Date
    Apr 2009
    Posts
    22

    Re: Moveable Frames

    very very thanks |2eM!x

  15. #15
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    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
  •  



Click Here to Expand Forum to Full Width