CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2010
    Posts
    5

    Keyword Highlighting Issue

    Hello,
    I have been working on a project which requires certain keywords such as added names and other keyword to be changed to a different color when typing in a rich edit. Currently, I am using EM_SETCHARFORMAT, however, this isn't what I presume to be the best solution to this issue. EM_SETCHARFORMAT requires that you set the highlighting and because of that it causes a lot of jumping in the control. I was wondering is there another message I could send that would be better? Or would I have to subclass it, and if that is the case, how would I go about doing something like that?

    Thank You.

  2. #2
    Join Date
    May 2010
    Posts
    5

    Re: Keyword Highlighting Issue

    Just to clarify by better, I mean something that does not require me to select the text I would like to format.

  3. #3
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Keyword Highlighting Issue

    To avoid all the jumping in the control, set the redraw to false, do the formatting, then set redraw to true.

    http://msdn.microsoft.com/en-us/libr...8VS.80%29.aspx

  4. #4
    Join Date
    May 2010
    Posts
    5

    Re: Keyword Highlighting Issue

    Thank You very much for your reply. I tried what you suggested and it did help. But not exactly what I was looking for, because WM_SETREDRAW adds lag in typing now.

  5. #5
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Keyword Highlighting Issue

    The trick is to just do one line at a time. Write two functions; one for a single line, and one for the whole control (or just the visible window). Handle the EN_CHANGE notification and only format one line unless the change is a carriage return or you have multi-line formating to deal with (like C's /* ... */ ).

  6. #6
    Join Date
    May 2010
    Posts
    5

    Re: Keyword Highlighting Issue

    I don't have to deal with multiple line keywords. About obtaining the single, I am able to obtain the text, however I would also like to know the offset from the entire text to that line. I am not exactly sure how to do that, I have looked through the MSDN references but haven't found anything of much use. Any help is appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured