如何判断鼠标点击的焦点是否在label上?
我是做这样的,很多个label 点击哪个哪个就变色,
再点击一个 上一个就恢复。
这个就是我要实现的。谁懂,提示一下
[解决办法]
丢了一句:
Option Explicit
Dim SelLabelIndex As Integer
Private Sub Label1_Click(Index As Integer)
Label1(SelLabelIndex).ForeColor = vbBlack
Label1(Index).ForeColor = vbRed
SelLabelIndex = Index
End Sub
Option Explicit
Private Sub Form_Load()
Dim vI As Long
Dim vJ As Long
Dim vX As Long
Dim vY As Long
Me.WindowState = 2
Me.Show
Label1(0).Move 0, 0, 180, 180
vX = (Me.Width - 120) \ 210 + 1
vY = (Me.Height - 630) \ 210 + 1
vJ = vX * vY - 1
For vI = 1 To vJ
Load Label1(vI)
Label1(vI).Move (vI Mod vX) * 210, (vI \ vX) * 210, 180, 180
Label1(vI).Visible = True
Next
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lbl As Label
For Each lbl In Label1
lbl.BackColor = vbRed
Next
End Sub
Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lbl As Label
For Each lbl In Label1
lbl.BackColor = IIf(lbl.Index = Index, vbBlue, vbRed)
Next
End Sub