Fuck ur code.
Code
Private MyRectangle As Rectangle
Private Drawing As Boolean = False
Private StartX, StartY, CursorX, CursorY As Single
Private Sub Region_Drag_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If Drawing = True Then
Dim Oral_Pen As New Pen(Brushes.Red, 2) 'Color and Size
Oral_Pen.DashStyle = Drawing2D.DashStyle.Solid 'Pattern
MyRectangle = New Rectangle(Min(StartX, CursorX), _
Min(StartY, CursorY), _
Abs(StartX - CursorX), _
Abs(StartY - CursorY))
e.Graphics.FillRectangle(New SolidBrush(Color.Transparent), MyRectangle)
e.Graphics.DrawRectangle(Oral_Pen, MyRectangle)
End If
End Sub
Private Sub Region_Drag_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Escape Then
Application.Exit() 'escape from expectations
End If
End Sub
Private Sub Region_Drag_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Me.BackColor = Color.Fuchsia 'or this
Me.Opacity = 100% 'Dont need this
Drawing = True
StartX = e.X
StartY = e.Y
CursorX = e.X
CursorY = e.Y
End Sub
Private Sub Region_Drag_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If Not Drawing Then Exit Sub
Dim G As Graphics = Me.CreateGraphics
CursorX = e.X
CursorY = e.Y
Me.Invalidate()
End Sub
Private Sub Region_Drag_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
Drawing = False
Dim G As Graphics = Me.CreateGraphics
G.DrawRectangle(Pens.Black, MyRectangle.X, MyRectangle.Y, MyRectangle.Width, MyRectangle.Height)
Me.Invalidate()
Me.Dispose()
End Sub
Private Sub Region_Drag_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Focus()
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.TopMost = True
Me.Location = New Point(0, 0)
Me.Size = Screen.PrimaryScreen.Bounds.Size
Me.DoubleBuffered = True
End Sub
Mine is easier to understand and more copy pastable for noobs.