CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Location
    C:\Windows\System32
    Posts
    47

    Post Add New line to multiline textbox

    Ok i've tryed to google it but not the results i need and not the right language so i'm gonna ask it here:

    How to add a new line to a multiline textbot control in Win32 Visual C++.

    And for example how to add the text to that textbox: Example
    Code:
    char Buffer = "a little buffer";
    char Buffer2 = GetDlgItemText(......);
    
    SetDlgItemText(hWnd, TXT1, Buffer + Buffer2);
    that seems to be an incorrect way and i can't seem to find the correct one >.<

    Any help will be useful.

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Add New line to multiline textbox

    You need to add a CR-LF pair for a new line in a multiline edit control. strcat() it to the first string, or make a third buffer with sprintf(). (Or use a string class like CString that supports "+" operator overloads).

  3. #3
    Join Date
    Feb 2009
    Location
    India
    Posts
    444

    Re: Add New line to multiline textbox

    CString Buffer1 = _T("a little buffer");
    CString Buffer2 = _T("another little buffer");

    CString Buffer3 += _T("\r\n");
    Buffer3 += Buffer2;

    SetDlgItemText(hWnd, TXT1, Buffer3);
    «_Superman
    I love work. It gives me something to do between weekends.

    Microsoft MVP (Visual C++)

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Add New line to multiline textbox

    First see How to append text to an edit control?.
    Also, as already suggested here, append a CR-LF ("\r\n") for a new line.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

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