How to move a borderless form in VB 08 [Tutorial]
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
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 !
Very good job, indeed Newbie friendly tutorial.
Dont forget to let people know about setting the Transparency Key and back color of form to the same color... ie: a color that does not clash with the design your are using as the form Background.
Good post
Good post
Last edited by hungryhounduk on Wed Nov 11, 2009 2:49 pm, edited 1 time in total.
There ARE easier ways or shorter ways :P
Copyright Information
Copyright © Codenstuff.com 2020 - 2023