CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    Surrey, England
    Posts
    23

    Line feeds and tabs in an edit control

    Hello,
    I am a beginner using VC++6.0 Professional on Windows 98

    I am writing an application which uses several views combined with a
    splitterbar as its first screen. One of these views is a CEditView,
    which is where my problem is.

    For the text of the CEditView I want to concatenate several text
    variables, with their contents each being shown on separate lines. I
    had tried to do it as follows:

    void CPTEditView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)

    {
    // TODO: Add your specialized code here and/or call the base class
    CEdit &pEdit = GetEditCtrl();
    CString mText = "All together ";
    CString Text1 = "this is written ";
    CString Text2 = "on several lines.";
    mText = mText + '\n' +Text1 + '\n' + Text2;
    pEdit.SetWindowText((LPCTSTR)mText);
    }



    However the edit control does not recognise the "\n" and merely prints
    all the text on a continuous line. I had also wanted to format some of
    the lines with tabs (ie "\t"), and these are not recognised either.

    I would be very grateful for code snippets showing me how to incorporate
    line feeds and tabs into my edit view.

    Hopefully,
    TrimTrom

    ----------------------
    Paul Trimming
    Surrey,England
    --------------------

  2. #2
    Join Date
    Aug 1999
    Location
    Minnesota
    Posts
    2

    Re: Line feeds and tabs in an edit control

    Try using "\r\n".


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