Code and Snippets for vb.net 2005
RSS icon Email icon Home icon
  • How to make borderless form draggable?

    Posted on May 7th, 2009 shyguy 7 comments

    Making a form without a border is nice to see especially when the user don’t want his form to minimize and maximize. I have here the following code that will make a borderless form draggable.

     

    ‘Declare these 2 variables with class scope
    Private Const WM_NCLBUTTONDOWN As Integer = &HA1S
    Private Const HTCAPTION As Integer = 2

    ‘Then handle your form.MouseDown event
    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
            Me.Capture = False
            Dim msg As Message = Message.Create(Me.Handle, WM_NCLBUTTONDOWN, New IntPtr(HTCAPTION), IntPtr.Zero)
            Me.DefWndProc(msg)
        End Sub

     

    7 responses to “How to make borderless form draggable?” RSS icon


    Leave a reply