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:

Mouse Over:

Mouse Leave:

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

Answers


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


Try This;

Mouse Over
Private Sub Button1_MouseHover(sender As Object, e As EventArgs) Handles Button1.MouseHover
    Button1.BackColor = Color.DodgerBlue
End Sub
Mouse Leave
Private Sub Button1_MouseLeave(sender As Object, e As EventArgs) Handles Button1.MouseLeave
    Button1.BackColor = Color.Red
End Sub

Need Your Help

Custom UpdateSourceTrigger with delay?

wpf data-binding binding updatesourcetrigger

I'm looking to create a custom version of UpdateSourceTrigger that I can use with my binding. I don't know if this is possible, or if instead, I'd need to just create my own binding class. What I'm

read icollection data using LINQ in C# code

c# linq entity-framework

I need to get Icollection data along with other data for each record instance using Linq query which I am doing right.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.