Solved

Edit controls- highlighting text and appending text simultaneously

Posted on 2000-04-12
6
198 Views
Last Modified: 2013-11-20
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
Comment
Question by:Bill Nolan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 2711040
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
 
LVL 7

Author Comment

by:Bill Nolan
ID: 2884382
Edited text of question.
0
 
LVL 7

Author Comment

by:Bill Nolan
ID: 2884383
Adjusted points from 30 to 80
0
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 
LVL 10

Accepted Solution

by:
RONSLOW earned 80 total points
ID: 3581813
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
 
LVL 7

Author Comment

by:Bill Nolan
ID: 3582432
Answer accepted
0
 
LVL 7

Author Comment

by:Bill Nolan
ID: 3582433
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question