A Revolution
From the Norm,
Towards Greatness
Home » » Visual Basic: Moving a Borderless Form

Visual Basic: Moving a Borderless Form

Written By Unknown on Monday, June 6, 2016 | 6:16 PM

Visual Basic: Moving a Borderless Form 

Welcome to today's tutorial in Visual Basic. This is a trick I learned about 3 - 4 years ago and I wanted to share with the blog because I believe it's a very helpful trick to learn.

What you will need?
  • Nothing, other than a form that is border-less 



Source Code
  1. Public Class Form1
  2.     Private mousex As Integer
  3.     Private mousey As Integer
  4.     Private dragged As Boolean = False
  5.     Private Sub Form1_MouseDown(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
  6.         If e.Button = MouseButtons.Left = True Then
  7.             dragged = True
  8.             mousex = e.X
  9.             mousey = e.Y
  10.         End If
  11.     End Sub
  12.     Private Sub Form1_MouseMove(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
  13.         If dragged = True Then
  14.             Dim oo As Point = New Point
  15.             oo.X = Me.Location.X + (e.X - mousex)
  16.             oo.Y = Me.Location.Y + (e.Y - mousey)
  17.             Me.Location = oo
  18.             oo = Nothing
  19.         End If
  20.     End Sub
  21.     Private Sub Form1_MouseUp(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
  22.         If e.Button = MouseButtons.Left = True Then
  23.             dragged = False
  24.         End If
  25.     End Sub
  26. End Class

SHARE

About Unknown

0 comments :

Post a Comment