Detect if mouse is over the entire form (included controls and aero border)
I want to detect when the mouse cursor is over the form (over the form mean over the form and also over any control of the form and also over the aero border), then if the mouse is over the ENTIRE "Form" then change the background of a picturebox, and when the mouse is not over the form (the client + nonclient area) then change again the picture.
This is an example:
I've tried to do it but no way... :
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
You could use a non selected image as the backing for the from and use mouse over on the image and if stretched all the way over the form that should work. Please correct me if i'm wrong
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