none
Need help understanding text highlighting behavior in response to a double-click RRS feed

  • Question

  • Hello all,

    I am writing a document that will describe C code - using Word (2007). 

    I plan to put C code excerpts into text boxes for display and organization within the document.  This much is simple.

    However, I'd also like to be able to double click on the C symbols within the code and have the entire symbol highlight so that the user can perform copy/paste operations easily.  The problem here is that C symbols include underscores, and it seems that the native behavior of Word is to see underscores as a non text character.  A second double click often gets me more than I wanted so thats not what im looking for either.

    Can anyone suggest a means of having Word interpret C/C++ symbols correctly (as any good code editor would)?

     

    Thanks for your help.

     

     

     

     

    Thursday, October 27, 2011 3:44 PM

Answers

  • My thought is that you'd have to harness the WindowBeforeDoubleClick event:

    http://msdn.microsoft.com/en-us/library/bb221344%28v=office.12%29.aspx

    Then have code which checks the text just outside of the selection, and expands the selection as appropriate.

     

    Are you writing a standalone executable in C++? Have you decided what method you're going to use for interop?

     

    EDIT:  Also, I hate myself for pointing it out, but what you're talk about is 'text selection'. 'Text highlighting' is something different word does.

     







    • Edited by JosephFox Saturday, October 29, 2011 8:14 PM Typo and sorted link
    • Marked as answer by Bruce Song Friday, November 4, 2011 8:51 AM
    Saturday, October 29, 2011 3:46 PM
  • Thanks for your reply, JosephFox.

    Good point, regarding text selection - your right, my mistatement.

    If time permits, Im going to look into the possibility of some kind of regex related solution, connected to a double click event.  The developer reference info you provided will be very helpful.

    Honestly, i was hoping for some kind of user setup option to provide the behavior im looking for.  No such luck though, I guess.

    Thanks again.

    • Marked as answer by JD_xl Monday, November 7, 2011 1:05 AM
    Monday, November 7, 2011 1:05 AM

All replies

  • My thought is that you'd have to harness the WindowBeforeDoubleClick event:

    http://msdn.microsoft.com/en-us/library/bb221344%28v=office.12%29.aspx

    Then have code which checks the text just outside of the selection, and expands the selection as appropriate.

     

    Are you writing a standalone executable in C++? Have you decided what method you're going to use for interop?

     

    EDIT:  Also, I hate myself for pointing it out, but what you're talk about is 'text selection'. 'Text highlighting' is something different word does.

     







    • Edited by JosephFox Saturday, October 29, 2011 8:14 PM Typo and sorted link
    • Marked as answer by Bruce Song Friday, November 4, 2011 8:51 AM
    Saturday, October 29, 2011 3:46 PM
  • Thanks for your reply, JosephFox.

    Good point, regarding text selection - your right, my mistatement.

    If time permits, Im going to look into the possibility of some kind of regex related solution, connected to a double click event.  The developer reference info you provided will be very helpful.

    Honestly, i was hoping for some kind of user setup option to provide the behavior im looking for.  No such luck though, I guess.

    Thanks again.

    • Marked as answer by JD_xl Monday, November 7, 2011 1:05 AM
    Monday, November 7, 2011 1:05 AM