Solved

Edit controls- highlighting text and appending text simultaneously

Posted on 2000-04-12
6
186 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 91
while loop over for loop 7 93
sum28 challenge 31 106
haveThree challenge 22 114
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

920 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now