Moving a Bordless Form in VisualBasic.NET
Ive seen this topic quite a bit in the VB.NET Forum I frequent; people wanting to move Borderless Forms and such. So here’s a tutorial to simply show you how easy it is.
First, we need to declare our variables:
Dim drag As Boolean
Dim mousex As Integer
Dim mousey As Integer
Next we need to tell the application its time to drag by setting drag to true and then letting the form know which way or location to head by getting the position of our Cursor:
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
drag = True
mousex = Windows.Forms.Cursor.Position.X - Me.Left
mousey = Windows.Forms.Cursor.Position.Y - Me.Top
End Sub
The code below actually does the moving of the Form for us. Since we clicked on the Form, drag was set to true so now as we move our mouse the Form will follow:
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If drag Then
Me.Top = Windows.Forms.Cursor.Position.Y - mousey
Me.Left = Windows.Forms.Cursor.Position.X - mousex
End If
End SubFinally, its time to stop dragging the form so as we release our mouse from the Form, drag needs to be set to false so it wont move anywhere until its clicked again:
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
drag = False
End Sub




February 20th, 2010 at 6:38 pm
My uncle took my computer to get it fixed after it got hit with a hard virus last year. he said there should be a virus protection on it, but i can’t find it anywher, I want to run a virus scan because something popped up telling me i have a virus. But i clicked off of it because i wasn’t sure if THAT was a virus or real. Where do I go in my computer to make sure i have a anti Virus protection, (and a fire wall) I want to download AVG to make sure, but will something bad happen if i try to download a virus protection IF i already have one that i dont know about? Thank you. santoramaa
February 20th, 2010 at 9:05 pm
If you have XP, Vista, or Windows 7 they have whats called a Windows Security Center which can be accessed through the Control Panel. It should tell you there if it detects a AntiVirus Software, whether you firewall is off or on, and a little about Windows Update. A lot of times the little pop ups you see telling you have a virus are scare ware applications, that’s even more true if you don’t have a AV Software installed. Your best bet is to get a trusted virus software from a respected source. Something like AVG, Kaspersky, NOD32; either from their websites or a place like CNet where they offer reviews for you to choose one for yourself. I’d recommend picking up one of those getting a full system scan performed and also use a Spyware application like Mal-ware bytes. It’s never a good idea to have two AV software applications on the same PC. Some people think you’re double protected but a lot of times it allows things to fall undetected.