how do i write text on a edit control created on the fly..,

This is a discussion on how do i write text on a edit control created on the fly.., within the Windows Programming forums, part of the Platform Specific Boards category; ie, m_hwndConsole = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("edit"), "", WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_MULTILINE, 0, 0, 200, ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    142

    how do i write text on a edit control created on the fly..,

    ie,

    m_hwndConsole = CreateWindowEx(WS_EX_CLIENTEDGE,
    TEXT("edit"),
    "",
    WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_MULTILINE,
    0,
    0,
    200,
    150,
    NULL,
    NULL
    GetModuleHandle(NULL),
    NULL);

    i've used SendMessage(...) which works(weather this control is a child or not), but i would really like to hear other people's opinion/idea on this,

    especially making the SetDlgItemText(...) to work which i can't,

    many thanks,

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    The SetWindowText function changes the text of the specified window’s title bar (if it has one). If the specified window is a control, the text of the control is changed.

    Code:
    BOOL SetWindowText(
    
        HWND hWnd,	// handle of window or control
        LPCTSTR lpString 	// address of string
       );
    Parameters

    hWnd

    Identifies the window or control whose text is to be changed.

    lpString

    Points to a null-terminated string to be used as the new title or control text.
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    If you create a ctrl on the fly it is a child of the dialog you create it on.
    It therefore has to be supplied a HWND of its parent to route its msg's to the correct callback and you must cast the HMENU as its individual int ID# (just as in the resource editor you must give the ctrl an name that is #defined to an int in resource.h)

    I use a series of #defines

    #define IDC_EDIT1 10001
    #define IDC_EDIT2 10002

    (HMENU)IDC_EDIT1//in your create window (ex) and then you can use a

    case IDC_EDIT1 in your callback or as the resource ID# in the API functions.
    Last edited by novacain; 06-28-2002 at 02:18 AM.
    "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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need to edit text from within my application.
    By spiroth10 in forum C++ Programming
    Replies: 2
    Last Post: 12-15-2006, 02:15 PM
  2. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 03:49 PM
  3. 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
  4. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 06:35 PM
  5. adding text to an edit control
    By steve_i83 in forum Windows Programming
    Replies: 2
    Last Post: 10-26-2001, 06:40 AM

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