PasteSite.Com

Recent Pastes

Sign Up!

PasteSite is open to the public, but with limited features. Register to be able to modify access rights, track your pastes and more...

Change the theme

If you prefer reading light text on a dark background to dark text on a light background, then you might want to try the dark theme.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Public Class Form3
    'This is what draws the area
    Public regionPen As Pen
 
    'The position and height/width of the selected region
    Dim pX, pY, nX, nY, rHei, rWid, rTop, rLeft As Integer
    Dim grabRegion As Rectangle
 
    Private Sub Form3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
 
        If e.Button = Windows.Forms.MouseButtons.Left Then 'We draw the square
            'Sets the new co-ordinates
            pX = e.Location.X
            pY = e.Location.Y
 
            'Clears the previous rectangle lines (Don't need hehe)
            Me.Refresh()
        End If
 
    End Sub
 
    Private Sub Form3_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        'Creates graphics object
        Dim Graphics As System.Drawing.Graphics = Graphics.FromHwnd(Me.Handle)
 
        'Clears the previous lines
        Me.Refresh()
 
        'Settings for the pen that draws selected area
        regionPen = New Pen(Color.SteelBlue, 1)
        regionPen.DashStyle = Drawing2D.DashStyle.Solid
 
        'The selected area position, height and width
        With grabRegion
            If pX > e.X Then .Width = pX - e.X Else .Width = e.X - pX ' Width of grab region
            If pY > e.Y Then .Height = pY - e.Y Else .Height = e.Y - pY 'Height of grab region
            If pY > e.Y Then .Y = e.Y Else .Y = pY
            If pX > e.X Then .X = e.X Else .X = pX
        End With
 
        'Draws the selected area
        Graphics.DrawRectangle(Pens.SteelBlue, grabRegion)
 
    End Sub
 
    Private Sub Form3_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
        'Clears rectangle
        Me.Refresh()
    End Sub
End Class

Reply to This Paste

(leave blank to make this paste permanent)
(if set as private)