title: Parent Control Mouse Enter/Leave Events With Child Controls
body: <p>I have a C# .NET 2.0 WinForms app.  My app has a control that is a container for two child controls: a label, and some kind of edit control.  You can think of it like this, where the outer box is the parent control:</p>
  
  <pre>
  +---------------------------------+ 
  | [Label Control]  [Edit Control] |
  +---------------------------------+</pre>
  
  <p>I am trying to do something when the mouse enters or leaves the parent control, but I don't care if the mouse moves into one of its children.  I want a single flag to represent "the mouse is somewhere inside the parent or children" and "the mouse has moved outside of the parent control bounds".</p>
  
  <p>I've tried handling MouseEnter and MouseLeave on the parent and both child controls, but this means the action begins and ends multiple times as the mouse moves across the control.  In other words, I get this:</p>
  
  <pre>
  Parent.OnMouseEnter      (start doing something)
  Parent.OnMouseLeave      (stop)
  Child.OnMouseEnter       (start doing something)
  Child.OnMouseLeave       (stop)
  Parent.OnMouseEnter      (start doing something)
  Parent.OnMouseLeave      (stop)</pre>
  
  <p>The intermediate OnMouseLeave events cause some undesired effects as whatever I'm doing gets started and then stopped.  I want to avoid that.</p>
  
  <p>I don't want to capture the mouse as the parent gets the mouse over, because the child controls need their mouse events, and I want menu and other shortcut keys to work.</p>
  
  <p>Is there a way to do this inside the .NET framework?  Or do I need to use a Windows mouse hook?</p>