Thread: Word Wrap

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    215

    Word Wrap

    Im working on this windows gui program and its a client/server program and Ive greated a readonly edit box that just displays data from the server, but when I used the function

    Code:
    SendMessage(hEdit,EM_REPLACESEL,0,line);
    the word wrap doesnt work, instead it goes on forever, and then finally goes to the next line only if the line is long enough, which it has to be very very long. I tried WM_SETTEXT but that would only put the last thing in the array line, so I was wondering if anyone knew something that would would make replacesel to go ot a new line nicely.

  2. #2
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    instead add
    Code:
    ES_MULTILINE | ES_READONLY
    to the createwindow for the edit control

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    215
    I already had it as readonly and mutliline.

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    17
    This may help you, if you're trying to do what I think you are.

    Code:
    void AppendWindowText(HWND hWnd, const char * lpString)
    {
      int iLength = GetWindowTextLength(hWnd);
      SendMessage(hWnd, EM_SETSEL, iLength, iLength);
      SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM) lpString);
      SendMessage(hWnd, WM_VSCROLL, SB_BOTTOM, (LPARAM)NULL);
    }
    hWnd being the handle to your edit control and lpString being the text you want to send there

    I use that code in a chat client I'm working on, just call that function when you need to add text to the edit control

  5. #5
    Registered User
    Join Date
    May 2004
    Posts
    215
    Hey hollowlife, thanks for the help, someone actually helped me with that, and its almost exactly like what you have posted. Im new to Win32 programming, so i just wanted to say thanks to all of you for helping me out!

    :-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing to a file with word wrap?
    By Djanvk in forum C++ Programming
    Replies: 1
    Last Post: 08-17-2008, 05:09 AM
  2. please help with binary tree, urgent.
    By slickestting in forum C Programming
    Replies: 2
    Last Post: 07-22-2007, 07:55 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Word Wrap
    By sethjackson in forum Windows Programming
    Replies: 4
    Last Post: 09-21-2005, 04:35 PM
  5. Wrong Output
    By egomaster69 in forum C Programming
    Replies: 7
    Last Post: 01-28-2005, 06:44 PM