Thread: Edit Control problem

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    28

    Edit Control problem

    I am trying to put default text into a Edit Control when I run my program. It sort of works, but if I want to put line feeds in, it screws up on the display.

    char *buff = "Temp.\n\rRar.";
    SetDlgItemText(hWnd, IDC_EDIT_TEXT, (LPCTSTR)buff);

    When I run this, the output in the window has two vertical bars where the \n\r are supposed to be. I just tried to copy and paste the output from my program, and those bars somehow turn into the carriage return when I paste it, but on the screen it looks wrong. If I run the program and hit enter within the edit control, it works just fine, so I think the problem has something to do with the way I send default text to my edit control.

    I've tried using

    SetWindowText(hList, buff);

    where hList is a handle to IDC_EDIT_TEXT, and it displays the text, but still has the same problem with the two bars appearing where the \n\r is supposed to be.

    I've tried switching to a rich edit control, but if I put a rich edit control on my dialog the program won't display anything, and I haven't found a way to fix that yet. I've tried the

    InitCommonControls();

    statement, but it doesn't seem to help. I'm not even sure making a rich edit field would fix the problem though.

    Any help would be appreciated. Thanks.
    -Grunt (Malek)

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Try using the edit style

    ES_MULTILINE

    the bars are the new line characters.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    28

    Multiline

    I have ES_MULTILINE selected (and the WANTRETURN style), but it also doesn't work. It allows me to hit enter and create line feeds with it when I'm actually typign in the box, but if I try to send default information to the text box it still shows those bars instead of \n\r characters.

    Another case where the bars show up is in a listbox. If I create a list box, and then go to Layout and Test in VC++, it has temporary data in the list box for me to play with. The last one says "tab|tab|tab" and has those bars again (where I put the | characters). I think those are supposed to be \t (or whatever tab is), but it screws up there too.

    If you have any other suggestions, please let me know.

    -----
    Originally posted by novacain
    Try using the edit style

    ES_MULTILINE

    the bars are the new line characters.
    -Grunt (Malek)

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    you need to put \r\n in an edit control
    "There are three kinds of people in the world...
    Those that can count and those that can't."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  2. Appending to an edit control
    By TheDan in forum Windows Programming
    Replies: 2
    Last Post: 03-31-2006, 12:27 PM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  4. Buttons + Edit Control
    By jay kay in forum Windows Programming
    Replies: 6
    Last Post: 03-09-2005, 05:36 PM
  5. Keeping focus on an edit control ...
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 02-19-2002, 02:12 AM