Solved

Edit controls- highlighting text and appending text simultaneously

Posted on 2000-04-12
6
185 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 30

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This video discusses moving either the default database or any database to a new volume.

708 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

15 Experts available now in Live!

Get 1:1 Help Now