How do you move a form with no title bar?? - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.