Need help with edit control

This is a discussion on Need help with edit control within the Windows Programming forums, part of the Platform Specific Boards category; Hi i'm writing a program that needs to append text to an edit control sort of like a chat program. ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    5

    Need help with edit control

    Hi i'm writing a program that needs to append text to an edit

    control sort of like a chat program. The problem i'm having is

    every time text is added it overwrites the old. Basically I want to

    be able to scroll up and look at what's been written. If anybody

    can help me at all or even understand what i'm babbling about it

    would be appreciated thanx .

  2. #2
    ENF
    ENF is offline
    Registered User
    Join Date
    Oct 2003
    Posts
    12
    use
    SendMessage(hWndEdit, EM_SETSEL, -1, -1);
    this moves cursor to the last place in the edit control then use EM_REPLACESEL (I think thats the correct name) and it will add new text to the end

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    5
    Does that add text to the end or on a new line. I need it on a new line and thanx for helping

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    To make a new line, place "\r\n" before the text you want added. Ie:
    Code:
    char *lpString=new char[64];
    
    lstrcat(lpString,"\r\n");
    lstrcat(lpString,"Text You Want Added");
    
    SendMessage(hEdit,EM_SETSEL,-1,-1);
    SendMessage( hEdit, EM_REPLACESEL,false, (LPARAM) lpString);
    
    delete [] lpString;
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can I send a text string to an edit control
    By marc74 in forum Windows Programming
    Replies: 5
    Last Post: 01-06-2005, 09:14 PM
  2. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  3. Restricting input to an edit control
    By bennyandthejets in forum Windows Programming
    Replies: 7
    Last Post: 10-05-2003, 01:10 AM
  4. endless edit control
    By ZerOrDie in forum Windows Programming
    Replies: 3
    Last Post: 03-21-2003, 01:51 AM
  5. Keeping focus on an edit control ...
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 02-19-2002, 01:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21