Code
Public Class Form1
Dim x, y, h, w, count As Single
Dim g As Graphics
Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
If e.Button = MouseButtons.Left Then
If count = 1 Then
x = e.X
y = e.Y
count = 2
Else
If e.X > x And e.Y > y Then
w = e.X - x
h = e.Y - y
g.DrawRectangle(Pens.Red, x, y, w, h)
End If
If e.X < x And e.Y < y Then
w = x - e.X
h = y - e.Y
g.DrawRectangle(Pens.Red, e.X, e.Y, w, h)
End If
If e.X > x And e.Y < y Then
w = e.X - x
h = y - e.Y
g.DrawRectangle(Pens.Red, x, e.Y, w, h)
End If
If e.X < x And e.Y > y Then
w = x - e.X
h = e.Y - y
g.DrawRectangle(Pens.Red, e.X, y, w, h)
End If
count = 1
End If
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
g = PictureBox1.CreateGraphics()
PictureBox1.BackColor = Color.White
PictureBox1.Cursor = Cursors.Cross
count = 1
End Sub
End Class
Делалось в Visual Studio 2005