Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

Edit controls- highlighting text and appending text simultaneously

I am using a CRichEditCtrl as sort of a chat window.  Text is appended to the bottom of the control as it comes in from the server.  If the user highlights some of the text, and then more text is appended to the bottom, it will remove the highlighting from the aforementioned text, since I am appending it using the CRichEditCtrl SetSel() and ReplaceSel() functions.  I suppose I could remember and restore any highlights upon writing text to the end of the control, but I am curious if there's a better way around this.  Either better way to save such selections, or even a different way to append text than using ReplaceSel().  Thanks for any ideas.
0
Bill Nolan
Asked:
Bill Nolan
  • 4
1 Solution
 
ZoppoCommented:
Hi Slimfinger,

You could try avoid that the control gets a EM_SELTEXT messages produced while text is appended in PreTranslateMessage() or in CRichEditCtrl-derived class.

ZOPPO
0
 
Bill NolanAuthor Commented:
Edited text of question.
0
 
Bill NolanAuthor Commented:
Adjusted points from 30 to 80
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
RONSLOWCommented:
turn off updates (SetRedraw or LockWindowUpdate) get the selection, set it to the end of file, replace the selection to append text, restore the selection and then turn updates back on.

That way you shouldn't see any change.

Another way to check the content is to use GetWindowText and SetWindowText to get the content, update it by adding more text and then shove it all back in again.  However, I don't know what this will do to your selection. You may still need to use the procedure above to stop flashing etc.
0
 
Bill NolanAuthor Commented:
Answer accepted
0
 
Bill NolanAuthor Commented:
This is basically what i did, though it is also basically what i proposed in the question, and stated i was hoping for a better way.  LockWindowUpdate isn't really necessary since it does not flash.  Anyway, no one else even answered, so thanks anyway.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now