现在我在用c#开发word,但是不知道有什么事件能够监听到鼠标在我word文档中的点击动作,有点类似于:当我在word中点击一个文字时工具栏会马上知道这个文字的字体格式;或者有没有开发word方面的API

解决方案 »

  1.   

    事件列表
    +-------------------------------------------------------------------------------+
    | 事件                    | 描述                                                |
    +-------------------------------------------------------------------------------+
    | Close                   | Occurs when a document is closed.                   |
    +-------------------------------------------------------------------------------+
    | DocumentBeforeClose     | Occurs immediately before any open document closes. |
    +-------------------------------------------------------------------------------+
    | DocumentBeforePrint     | Occurs before any open document is printed.         |
    +-------------------------------------------------------------------------------+
    | DocumentBeforeSave      | Occurs before any open document is saved.           |
    +-------------------------------------------------------------------------------+
    | DocumentChange          | Occurs when a new document is created, when an      |
    |                         | existing document is opened, or when another        |
    |                         | document is made the active document.               |
    +-------------------------------------------------------------------------------+
    | DocumentOpen            | Occurs when a document is opened.                   |
    +-------------------------------------------------------------------------------+
    | GotFocus                | Occurs when the focus is moved to an embedded       |
    |                         | ActiveX control.                                    |
    +-------------------------------------------------------------------------------+
    | LostFocus               | Occurs when the focus is moved from an embedded     |
    |                         | ActiveX control.                                    |
    +-------------------------------------------------------------------------------+
    | New                     | Occurs when a new document that is based on the     |
    |                         | template is created. A procedure for the New event  |
    |                         | runs only if it is stored in a template.            |
    +-------------------------------------------------------------------------------+
    | NewDocument             | Occurs when a new document is created.              |
    +-------------------------------------------------------------------------------+
    | Open                    | Occurs when a document is opened.                   |
    +-------------------------------------------------------------------------------+
    | Quit                    | Occurs when the user quits Word.                    |
    +-------------------------------------------------------------------------------+
    | WindowActivate          | Occurs when any document window is activated.       |
    +-------------------------------------------------------------------------------+
    | WindowBeforeDoubleClick | Occurs when the editing area of a document window   |
    |                         | is double-clicked, before the default double-click  |
    |                         | action.                                             |
    +-------------------------------------------------------------------------------+
    | WindowBeforeRightClick  | Occurs when the editing area of a document window   |
    |                         | is right-clicked, before the default right-click    |
    |                         | action.                                             |
    +-------------------------------------------------------------------------------+
    | WindowDeactivate        | Occurs when any document window is deactivated.     |
    +-------------------------------------------------------------------------------+
    | WindowSelectionChange   | Occurs when the selection changes in the active     |
    |                         | document window. 这个可能对你有用                   |
    +-------------------------------------------------------------------------------+
      

  2.   

    如果是在word中的字那还真是不好处理,因为word本身是有样式的,而你的外部环境中很难模拟出和word一样的样式和环境
      

  3.   

    可能我问题表述的不是很清楚,我重新把问题整理一下,问题如下:
       我在word中点击鼠标或者通过键盘移动使光标位置发生变化,有没有什么事件能够监听到光标的位置,以便于我可以根据光标的位置不同,来进行不同的操作,如果能够贴下代码的话那就最好啦,主要是学习c#没多久,很多都不懂。
       WindowSelectionChange这个事件应该是可行的,就是具体代码不知道该怎么写
      

  4.   

    难道是VSTO?
    不是很懂,捕捉光标的问题ms要用hook
      

  5.   

    WindowSelectionChange这个事件确实可行