Public
Class
Form1
Dim
p
As
New
Pen(Color.White, 5)
Dim
mousePos
As
Point
Dim
Rct(5)
As
Rectangle, r
As
Integer
= 0
Private
Sub
Form1_Load(
ByVal
sender
As
Object
, _
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
Rct(1) =
New
Rectangle(30, 30, 94, 73)
Rct(2) =
New
Rectangle(30, 131, 94, 73)
Rct(3) =
New
Rectangle(30, 232, 94, 73)
Rct(4) =
New
Rectangle(30, 334, 94, 73)
Rct(5) =
New
Rectangle(30, 439, 94, 73)
End
Sub
Private
Sub
Form1_MouseMove(
ByVal
sender
As
Object
, _
ByVal
e
As
System.Windows.Forms.MouseEventArgs)
Handles
Me
.MouseMove
mousePos.X = Control.MousePosition.X -
Me
.Left - 5
mousePos.Y = Control.MousePosition.Y -
Me
.Top - 30
r = 0
Label1.Text =
"X: "
& mousePos.X
Label2.Text =
"Y: "
& mousePos.Y
Me
.Invalidate()
If
mousePos.X >= 30
And
mousePos.X <= 124
And
_
mousePos.Y >= 30
And
mousePos.Y <= 30 + 73
Then
r = 1
Me
.Invalidate()
End
If
If
mousePos.X >= 30
And
mousePos.X <= 124
And
_
mousePos.Y >= 131
And
mousePos.Y <= 131 + 73
Then
r = 2
Me
.Invalidate()
End
If
If
mousePos.X >= 30
And
mousePos.X <= 124
And
_
mousePos.Y >= 232
And
mousePos.Y <= 232 + 73
Then
r = 3
Me
.Invalidate()
End
If
If
mousePos.X >= 30
And
mousePos.X <= 124
And
_
mousePos.Y >= 334
And
mousePos.Y <= 334 + 73
Then
r = 4
Me
.Invalidate()
End
If
If
mousePos.X >= 30
And
mousePos.X <= 124
And
_
mousePos.Y >= 439
And
mousePos.Y <= 439 + 73
Then
r = 5
Me
.Invalidate()
End
If
End
Sub
Private
Sub
Form1_Paint(
ByVal
sender
As
Object
, _
ByVal
e
As
System.Windows.Forms.PaintEventArgs)
Handles
Me
.Paint
e.Graphics.DrawRectangle(p, Rct(r))
End
Sub
End
Class