Click to See Complete Forum and Search --> : CEdit::ReplaceSel


Todd Casey
April 22nd, 1999, 11:48 AM
I have created a MFC app which has a CEditView. I am able to GetSelectedText which has been selected and modify this text to add to it. Now that I have retrieved the selected text and modified the text I need to return this text to the selection. I have tried using the ReplaceSel( string, FALSE ) and the compiler says that ReplaceSel is an undeclared identifer. This is what I have so far.

void CMyEditView::OnBold()
{
CString strResult;
GetSelectedText( strResult );
strResult = "<bold>" + strResult + "<bold>";
ReplaceSelected( strResult, FALSE );
}

When the user clicks my Bold menu opion after they have selected a block of text I grab the selected text and add the two html tags <bold> to the front and back end. Now I need to return this into the selected text. I would appriciate any help anyone could give me. Thanks.

Todd Casey
todd@jack-bilt.com

DustinW
April 22nd, 1999, 11:58 AM
CEditView does not have a ReplaceSel method.

Use the CEditView::GetEditCtrl() method which returns a reference to a CEdit (edit control) then call CEdit::ReplaceSel(). Like this:

GetEditCtrl().ReplaceSelected( strResult, FALSE );