How to set the multiline text in the EditBox programmatically

This is a discussion on How to set the multiline text in the EditBox programmatically within the Windows Programming forums, part of the Platform Specific Boards category; I have a following dialog Code: IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75 STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION ...

  1. #1
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484

    How to set the multiline text in the EditBox programmatically

    I have a following dialog
    Code:
    IDD_ABOUTBOX DIALOG DISCARDABLE  22, 17, 230, 75
    STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
    CAPTION "About"
    FONT 8, "System"
    BEGIN
        ICON            IDI_MYPLAYER,IDC_MYICON,14,9,20,20
        LTEXT           "MyPlayer Version 1.0",IDC_STATIC,49,10,119,8,
                        SS_NOPREFIX
        LTEXT           "Copyright (C) 2007",IDC_STATIC,49,20,119,8
        DEFPUSHBUTTON   "OK",IDOK,195,6,30,11,WS_GROUP
        EDITTEXT        IDC_OSVER,49,36,144,32,ES_MULTILINE | ES_AUTOVSCROLL | 
                        ES_AUTOHSCROLL | ES_READONLY
    END
    In the Dialog procedure I do the following:

    Code:
    switch (message)
    {
    	case WM_INITDIALOG:
    	{
                  SetDlgItemText(hDlg,IDC_OSVER,"Hello\nworld");
    	}
    	return TRUE;
    ...
    }
    But the text does not split in two lines... It is shown on one line.
    And if the text is longer than the EditBox - the scroll bar does not appears...

    How could I add the multiline text to the Multiline editbox on dilog opening, so the scrollbars will be visible when needed?
    Last edited by vart; 07-20-2007 at 11:33 PM.
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  2. #2
    Registered User
    Join Date
    Jul 2007
    Posts
    36
    It might be better to use a richedit control.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,672
    > "Hello\nworld"
    You could try the other combinations of "\r" or "\r\n".
    It seems likely they would have used what the native file system used when this was first invented.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Thanks

    \r\n did the trick.

    There is the second problem left:
    When the text is longer than edit control the scroll bar does not appers.
    I thought ES_AUTOHSCROLL is enough to show the scrollbar... Should I sent some additional message?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    WS_HSCROLL and/or WS_VSCROLL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. optimising program
    By SONU in forum C Programming
    Replies: 1
    Last Post: 05-18-2008, 10:28 AM
  2. Set Classes
    By Nicknameguy in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2002, 07:40 PM
  3. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM
  4. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 05:05 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 06:35 PM

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