none
How to determine mouse cursor is located on or near content control? RRS feed

  • Question

  • Hi,

     

    I am stumped with a rather urgent problem in a VSTO SE Add-in I am developing in Word 2007. 

     

    In WindowSelectionChange event, I need to know where the user's cursor is located in relation to a given range (as defined by a content control).  I need to know, when the user clicks the mouse, if it is located on or near the currently-highlighted content control range.

     

    If there is no straightforward way of doing this with mouse coordinates, then I have another plan. Is there a way to determine if the user has the mouse inside the document editing area (as indicated by an I-beam), or outside of it (such as over the header or footer in which case cursor turns into an arrow).  Note: I tried to do this using the System.Cursor property but it returns wdCursorNormal regardless of whether it is actually an IBeam at the time that I click the document window to trigger the WindowSelectionChange event.

     

    Thanks much for any help.

     

    Thursday, October 18, 2007 10:11 PM

Answers

  • There is nothing in either the Word or the VSTO object models that lets you work with the mouse. You can't determine its location in relation to anything in the Word document window.

     

    Once the user has clicked, then you can determine where the selection is.

     

    Possibly, you could manage something using the Windows API, as far as getting the mouse co-ordinates. But figuring out where these are in relation to what's displayed on a document in the Word window...
    Friday, October 19, 2007 8:59 AM
    Moderator