CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    43

    CEdit::ReplaceSel

    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
    [email protected]


  2. #2
    Join Date
    Apr 1999
    Posts
    5

    Re: CEdit::ReplaceSel

    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 );



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured