我想检测鼠标光标何时位于表单上方(在表单上方,表单上方以及表单的任何控件以及空中边框上),然后如果鼠标位于整个“表单”上然后更改图片框的背景,当鼠标不在表单(客户端+非客户区域)上时,再次更改图片。
这是一个例子:
鼠标悬停:
鼠标离开:
我试过这样做,但没办法......:
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
答案 0 :(得分:0)
您可以使用未选择的图像作为from的支持,并在图像上使用鼠标,如果在应该工作的表单上一直拉伸。 如果我错了,请纠正我
答案 1 :(得分:0)
试试这个;
Private Sub Button1_MouseHover(sender As Object, e As EventArgs) Handles Button1.MouseHover
Button1.BackColor = Color.DodgerBlue
End Sub
Private Sub Button1_MouseLeave(sender As Object, e As EventArgs) Handles Button1.MouseLeave
Button1.BackColor = Color.Red
End Sub