|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
detect mouse leaves controlI can't figure out how to detect when my mouse cursor leaves a panel control. It should not trigger the event (or do anything) when the mouse leave the panel but still is over a control that is contained by the panel. I've done this : Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) If Cursor.Position.X > Me.Location.X + Me.Width Or Cursor.Position.Y > Me.Location.Y + Me.Height _ Or Cursor.Position.X < Me.Location.X Or Cursor.Position.Y < Me.Location.Y Then MsgBox("Out") End If End Sub That doesn't work well. what is the correct method ? Thx Hi,
Capture the mouse when it enters the panel. Check and see if the mouse is inside the panel when it moves. Release it when it exits. Private Sub Panel1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel1.MouseEnter Panel1.Capture = True End Sub Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove Dim pt As New Point(e.X, e.Y) If Not Panel1.ClientRectangle.Contains(pt) Then Me.Text = "out of panel" Panel1.Capture = False Else Me.Text = "in panel" End If End Sub Ken --------------------------------- "Sam" <samuel.berthe***@voila.fr> wrote in message I can't figure out how to detect when my mouse cursor leaves a panelnews:1119901648.997544.190000@g44g2000cwa.googlegroups.com... Hi, control. It should not trigger the event (or do anything) when the mouse leave the panel but still is over a control that is contained by the panel. I've done this : Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) If Cursor.Position.X > Me.Location.X + Me.Width Or Cursor.Position.Y > Me.Location.Y + Me.Height _ Or Cursor.Position.X < Me.Location.X Or Cursor.Position.Y < Me.Location.Y Then MsgBox("Out") End If End Sub That doesn't work well. what is the correct method ? Thx
"Handles" Question
Checking for a valid date convert date and time formats vb.net Threading Question Embedded resource namespace code generator received malformed input Registry Key Permissions C# supports pointer. can you create one "MouseEnter" event handler for multiple controls on a form? size and position |
|||||||||||||||||||||||