How do you move a form with no title bar??

I need to let the user move a form that has no title bar on it. Any ideas how to do this??


Thanks

Paul Sprague


Comments

  • There is a Windows function called sendmessage that can be used to do this. However, I can never remember the syntax so I use this instead:


    First, put a label called Label1 (or rewrite the code for whatever control, or the form itself) on your form, then make three global integers called DragIt, MoveX and MoveY, then:


    Sub Label1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)


    MoveX = X

    MoveY = Y

    DragIt = True


    End Sub


    Sub Label1_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)


    If DragIt And (WindowState = 0) Then

    Me.Move Me.Left + (X - MoveX), Me.Top + (Y - MoveY)

    End If


    End Sub


    Sub Label1_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)


    DragIt = False


    End Sub


    Works perfectly for me, hope it helps you out!


  • Works great.


    Thanks

    Paul Sprague




    : There is a Windows function called sendmessage that can be used to do this. However, I can never remember the syntax so I use this instead:


    : First, put a label called Label1 (or rewrite the code for whatever control, or the form itself) on your form, then make three global integers called DragIt, MoveX and MoveY, then:


    : Sub Label1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)


    : MoveX = X

    : MoveY = Y

    : DragIt = True


    : End Sub


    : Sub Label1_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)


    : If DragIt And (WindowState = 0) Then

    : Me.Move Me.Left + (X - MoveX), Me.Top + (Y - MoveY)

    : End If


    : End Sub


    : Sub Label1_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)


    : DragIt = False


    : End Sub


    : Works perfectly for me, hope it helps you out!





Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories