我想检测鼠标光标何时在表单上(在表单上意味着在表单上以及在表单的任何控件上以及在航空边框上),然后如果鼠标在整个“表单”上,则更改图片框的背景,当鼠标不在窗体(客户端+非客户端区域)上时,再次更改图片。
这是一个例子:
鼠标移到:
鼠标离开:
我试过这样做,但没有办法......:
Private Sub Form1_MouseHover(sender As Object, e As EventArgs) Handles _
Me.MouseHover, _
PictureBox_Color.MouseHover, _
Label_HEX.MouseHover, _
Label_HEX_Value.MouseHover, _
Label_HTML.MouseHover, _
Label_HTML_Value.MouseHover, _
Label_RGB.MouseHover, _
Label_RGB_Value.MouseHover, _
Label_CTRL_C.MouseHover, _
Label_CTRL_S.MouseHover, _
Label_CTRL_X.MouseHover, _
RadioButton_HEX.MouseHover, _
RadioButton_HTML.MouseHover, _
RadioButton_RGB.MouseHover, _
CheckBox_Copy_Syntax.MouseHover, _
Panel1.MouseHover
Timer1.Stop()
Label_RGB_Value.Text = "0"
Label_HEX_Value.Text = "0"
Label_HTML_Value.Text = "0"
PictureBox_Color.BackgroundImage = My.Resources.Elektro
End Sub
Private Sub Form1_MouseLeave(sender As Object, e As EventArgs) Handles _
Me.MouseLeave, _
PictureBox_Color.MouseLeave, _
Label_HEX.MouseLeave, _
Label_HEX_Value.MouseLeave, _
Label_HTML.MouseLeave, _
Label_HTML_Value.MouseLeave, _
Label_RGB.MouseLeave, _
Label_RGB_Value.MouseLeave, _
Label_CTRL_C.MouseLeave, _
Label_CTRL_S.MouseLeave, _
Label_CTRL_X.MouseLeave, _
RadioButton_HEX.MouseLeave, _
RadioButton_HTML.MouseLeave, _
RadioButton_RGB.MouseLeave, _
CheckBox_Copy_Syntax.MouseLeave, _
Panel1.MouseLeave
If ((MousePosition.X < Me.Location.X) Or MousePosition.X > (Me.Location.X + Me.Width)) _
AndAlso ((MousePosition.Y < Me.Location.Y) Or MousePosition.Y > (Me.Location.Y + Me.Height)) Then
Timer1.Start()
PictureBox_Color.BackgroundImage = Nothing
End If
End Sub