How to move a borderless form in VB 08 [Tutorial]
Posted: Sun Nov 01, 2009 3:09 am
Newbie friendly Tutorial
Here's a rare tutorial which a lot of people don't know , this tutorial will teach you how to move your form when you set your form border to NONE ( A borderless form cannot move )
What can you do with a borderless form ?
You can add any beautiful or amazing designs to your programs
First , you need to have Visual basic 2008 .
1.Open up your visual basic and select File > New Project (ctrl+N) > Windows Form Application > Name it anything you like
When successfully opened it , it will look like this :
![Image]()
2.Select the form , set the "FormBorderStyle" to "None" that is in the form properties .
![Image]()
This will make your form border to dissapear
3.Ok now , lets press debug , you can see that the form cannot move .
4.Ok , double click on the form and you will go into "Form1.vb" (The code page)
Then copy and paste the code below into Form1.vb (Paste it below "Public Class Form1"):
Dim NewPoint As New System.Drawing.Point()
Dim X, Y As Integer
Private Sub Form1_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If e.Button = MouseButtons.Left Then
NewPoint = Control.MousePosition
NewPoint.X -= (X)
NewPoint.Y -= (Y)
Me.Location = NewPoint
End If
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
X = Control.MousePosition.X - Me.Location.X
Y = Control.MousePosition.Y - Me.Location.Y
End Sub
5.Ok , now press debug again and you can move the form !
:lol:
Hope that helps .
[Extra!]
If you want to add a close button , just add a button , double click on it , type in "Me.close" . Debug it and when you click on the button the form will close !
Here's a rare tutorial which a lot of people don't know , this tutorial will teach you how to move your form when you set your form border to NONE ( A borderless form cannot move )
What can you do with a borderless form ?
You can add any beautiful or amazing designs to your programs
First , you need to have Visual basic 2008 .
1.Open up your visual basic and select File > New Project (ctrl+N) > Windows Form Application > Name it anything you like

When successfully opened it , it will look like this :
2.Select the form , set the "FormBorderStyle" to "None" that is in the form properties .
This will make your form border to dissapear
3.Ok now , lets press debug , you can see that the form cannot move .
4.Ok , double click on the form and you will go into "Form1.vb" (The code page)
Then copy and paste the code below into Form1.vb (Paste it below "Public Class Form1"):
Dim NewPoint As New System.Drawing.Point()
Dim X, Y As Integer
Private Sub Form1_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If e.Button = MouseButtons.Left Then
NewPoint = Control.MousePosition
NewPoint.X -= (X)
NewPoint.Y -= (Y)
Me.Location = NewPoint
End If
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
X = Control.MousePosition.X - Me.Location.X
Y = Control.MousePosition.Y - Me.Location.Y
End Sub
5.Ok , now press debug again and you can move the form !
:lol:
Hope that helps .
[Extra!]
If you want to add a close button , just add a button , double click on it , type in "Me.close" . Debug it and when you click on the button the form will close !