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

CRichEditCtrl::clear() doesn't work???

869 views
Skip to first unread message

scdong

unread,
Aug 18, 2008, 5:53:42 AM8/18/08
to
Hi,
I'm using the following code snippet to clear the rich edit control
when i want to refresh its content:
mRichEditCtrl.SetReadOnly(FALSE);
mRichEditCtrl.SetSel(0, -1);
mRichEditCtrl.Clear();
But it's doesn't work. What should I do? I'm using VS2008 and want to
Rich Edit 2.0 for localized language. Any ideas are welcome.

Thanks
-Jerry

AliR (VC++ MVP)

unread,
Aug 18, 2008, 12:35:12 PM8/18/08
to
It works fine when I do it!

how about:
mRichEditCtrl.SetWindowText(_T(""));

AliR.


"scdong" <shichon...@gmail.com> wrote in message
news:251cbf87-e5f7-49db...@x16g2000prn.googlegroups.com...

scdong

unread,
Aug 18, 2008, 11:18:44 PM8/18/08
to
I have debugged the code, the window text actually has been set to
empty, but it doesn't refresh the UI. So when i want to outout
something in rich edit control, the new output is followed by previous
output. All I want is to clear the UI, so i can output in the start of
the client area of rich edit control.

BobF

unread,
Aug 19, 2008, 6:51:24 AM8/19/08
to

This works for me:

m_REventDisplay.SetSel(0, -1);
m_REventDisplay.Clear();

Phil Outram

unread,
Feb 4, 2011, 10:49:41 AM2/4/11
to
It may be that your RichEditCtrl is inadvertently protected, i.e. has /protected (or similar, can't quite remember) RTF tag somewhere. If that's the case, you can trap an EN_PROTECTED message when the user is taking an action that would change the protected range of text. Trap this message by calling ctrl.SetEventMask(ctrl.GetEventMask() | ENM_PROTECTED); before making any calls to change the text.

When handling the EN_PROTECTED message (which is sent to the control's parent unless it's reflected back to the control), if you return FALSE, the action is permitted, despite the protected state; returning TRUE dumps the action and the computer beeps.

Hope this helps. Had me for a while.


>> On Monday, August 18, 2008 12:35 PM AliR \(VC++ MVP\) wrote:

>> It works fine when I do it!
>>
>> how about:
>> mRichEditCtrl.SetWindowText(_T(""));
>>
>> AliR.


>>> On Tuesday, August 19, 2008 6:51 AM BobF wrote:

>>> scdong wrote:
>>>
>>> This works for me:
>>>
>>> m_REventDisplay.SetSel(0, -1);
>>> m_REventDisplay.Clear();


>>>> On Friday, August 22, 2008 12:46 AM scdong wrote:

>>>> I have debugged the code, the window text actually has been set to
>>>> empty, but it doesn't refresh the UI. So when i want to outout
>>>> something in rich edit control, the new output is followed by previous
>>>> output. All I want is to clear the UI, so i can output in the start of
>>>> the client area of rich edit control.


>>>> Submitted via EggHeadCafe
>>>> SharePoint Tip / Thought of the Day WebPart
>>>> http://www.eggheadcafe.com/tutorials/aspnet/14280ff8-3c9f-46bd-8214-9267e613c8ec/sharepoint-tip--thought-of-the-day-webpart.aspx

0 new messages