Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to un-hightlight the text in Rich Edit Control?

0 views
Skip to first unread message

scdong

unread,
Oct 14, 2008, 4:01:02 AM10/14/08
to
Hi all,
I have a read-only Rich Edit Control in dialog and insert text into it
via code. When the dialog pops up, all the text in Rich Edit Control
are highlighted as they are selected. How to un-hightlight them by
code? Thanks in advance.

Jerry

BobF

unread,
Oct 14, 2008, 5:53:22 AM10/14/08
to

Quick & Easy, moving the caret should do the trick. Or look around
here: <http://msdn.microsoft.com/en-us/library/68730ktd(VS.80).aspx>

scdong

unread,
Oct 15, 2008, 11:02:22 PM10/15/08
to
Hi,
Thanks for your reply. I want to use HideSelection() to un-highlight
all the inserted text by:
mRichEditCtrl.HideSelection(TRUE, TRUE);
But it doesn't work. And i also have tried to unselect all the
inserted text, but it also doesn't work.

Thanks
-Jerry

David Ching

unread,
Oct 22, 2008, 9:25:50 PM10/22/08
to

"scdong" <shichon...@gmail.com> wrote in message
news:1fba9afe-610d-4255...@r66g2000hsg.googlegroups.com...


This code positions the caret and removes the highlight. You can experiment
with nChar - try setting it to 0 or -1.

void CViewRtf::PositionCaret (long nChar)
{
m_RichEditCtrl.SetSel (nChar, nChar);
}


-- David

Joseph M. Newcomer

unread,
Oct 22, 2008, 11:01:17 PM10/22/08
to
Where do you want the selection to be after the insertion? At the front of the insertion
or the back of the insertion?

You could use SetSel to do this. One misfeature of edit controls is a continuing Bad Idea
that setting the focus to a control should necessarily select all the text in the control;
this is different from adding text via some technique such as ReplaceSel. I once saw how
to disable this, but I've now forgotten.
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

0 new messages