Mouse events entering and exiting forms RRS feed

  • Question

  • I'm developing a Word 2007 add-in using Visual Studio 2008 on a Vista Computer.  The add in will require frequent interation between a form (topmost) and the active Word document.  The issue is when the user clicks on the form the active document loses focus so that when they return to the document they need to click the document twice to retrieve data from the document to the form, once for the document to gain focus and the second time to select the data.   The user clicks a button to add the data to a text box on the form.  This does not flow very well.  I would like to switch between the form and the Word document so that when the mouse enters the form, the form gains focus and when the mouse leaves the form, the document gains focus.  This would allow the form to work similar to function dialog boxes in excel.   I tried using mouseenter and mouseleave events to track the location of the mouse for this purpose.  Unfortunately its not that easy.  The form has several controls such as buttons and a text box.  The mouse enter event fires when the mouse first enters the form, but the mouseleave event fires when the mouse enters one of the controls on the form.  This is not what I want.  I need the mouse events to fire based on entering and leaving the form only.  I took a stab at Win32 API but the language is foreign to me and I think Microsoft is switching from API to WPF anyway.  Is it possible to do what I want or is that just the way it is?

    Thanks in advance

    Wednesday, October 29, 2008 1:53 PM


All replies