Solved

Edit controls- highlighting text and appending text simultaneously

Posted on 2000-04-12
6
187 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:Slimfinger
  • 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:Slimfinger
ID: 2884382
Edited text of question.
0
 
LVL 7

Author Comment

by:Slimfinger
ID: 2884383
Adjusted points from 30 to 80
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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:Slimfinger
ID: 3582432
Answer accepted
0
 
LVL 7

Author Comment

by:Slimfinger
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Rewrite URL With Encoded Characters 6 79
notReplace  challenge 53 131
if loop in java 3 142
viewing source code from eclipse 13 108
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

831 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