473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

detect mouse leaves control

Sam
Hi,
I 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

Nov 21 '05 #1
2 4961
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" <sa**************@voila.fr> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi,
I 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
Nov 21 '05 #2
Sam
Thank you so much, it works just fine !
thank you again :)

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: selowan | last post by:
Hi, In VB6 Pro SP5, I have a form that contains an MSFlexGrid and a few other textboxes and comboboxes. I am using the technique from MSDN article Q241355, which describes how to tab and edit in...
2
by: Eitan | last post by:
Hello, I am creating a new window class based on CWnd. I am placing it on the View (CFormView). How can I get the notification or any other indication that the cursor/mouse is not on this...
0
by: Eitan | last post by:
Hello, I am creating a new window class based on CWnd. I am placing it on the View (CFormView). How can I get the notification or any other indication that the cursor/mouse is not on this...
3
by: Qwert | last post by:
Hello, if you have a WebCustomControl ( inherits from System.Web.UI.WebControls.WebControl ), how do you create an event that responses to the movement of the cursor above the control? ...
2
by: bretth | last post by:
In a VB.Net Windows Forms application, I have a user control that handles mouse events. Another section of code programmatically adds a label to the control. I would like label to ignore all...
4
by: ronchese | last post by:
Hello! I have a UserControl that have two other controls inside it. I need to set a different border color for my UserControl when the mouse enters it, and restore the border color when the...
4
by: cb.brite | last post by:
Hello, I have tried this using the MouseEnter/MouseLeave events. However these events do not really refer to the rectangular shape of the form, but the client area (form area minus children...
5
by: Zaxxon21 | last post by:
I'm basically trying to implement a simple drop down menu list for a button that I have. When the user hovers over the button, I want a list of button options to appear below the button. If the...
0
by: Frank Rizzo | last post by:
I have a form with a lot of controls on it. How can I detect when the mouse leaves the form? I've tried wiring up a MouseLeave event for every single control, but that does not work because those...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.