VB.NET 2019 || How to move custom bordless form

Опубликовано: 13 Июль 2026
на канале: BRQ RaVeN
84
0

you need 3 buttons + timer
code is :
.................................
Public Class Form1
Dim oldmousepoint As Point
Dim differentpoint As Point

' we need here to calculate the difference between the old mouse position and the new mouse position
' and then add that difference to form location

Private Sub Btnexit_Click(sender As Object, e As EventArgs) Handles btnexit.Click
Application.Exit()
End Sub

Private Sub Btnminimize_Click(sender As Object, e As EventArgs) Handles btnminimize.Click
Me.WindowState = FormWindowState.Minimized
End Sub

Private Sub BtnmoveForm_MouseDown(sender As Object, e As MouseEventArgs) Handles btnmoveForm.MouseDown
oldmousepoint = MousePosition
Timer1.Start()
End Sub

Private Sub BtnmoveForm_MouseUp(sender As Object, e As MouseEventArgs) Handles btnmoveForm.MouseUp
Timer1.Stop()
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Not oldmousepoint = MousePosition Then
Me.Location = Me.Location + differentpoint
End If
differentpoint = MousePosition - oldmousepoint
oldmousepoint = MousePosition
End Sub
End Class