Thread: sending message to textbox

  1. #1
    Registered User Boomba's Avatar
    Join Date
    Jun 2003
    Posts
    89

    sending message to textbox

    is there a way to use Sendmessage to send text stored in a variable to a textbox? What type of msg do i use....I cant seem to find the list of possible messages that can be used with SendMessage(...it would be great if someone could tell me where I couldfind a complete list cus they seem to be all over the place..on msdn at least.

    or should I use SetWindowtext?

    thanx in advance,
    Boomba

  2. #2
    koverli
    Guest
    Use the WM_SETTEXT message.
    If you use MSDN, scroll to the bottom of the WM_SETTEXT explaination, and press the link "Window messages"

  3. #3
    Registered User Boomba's Avatar
    Join Date
    Jun 2003
    Posts
    89
    OK thanx that works... how do I append whats already written in the textbox?..becasue I'm reading in from several files with a loop so everytime I send a message to the texbox I want it to add on to whats already there.

    thanx,
    Boomba

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    WM_GETTEXT or GetDlgItemText() or GetWindowText()

    then join the strings and set the text.

    WM_GETTEXTLENGTH or GetWindowTextLength() may help in ensuring there is enough space in your buffer (or allocating the required space)
    "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

  5. #5
    Registered User Boomba's Avatar
    Join Date
    Jun 2003
    Posts
    89
    and how do I make it so that my textbox developes a vertical scrollbar when the text hits the last line and continues down.

    thanx in advance,
    Boomba
    Last edited by Boomba; 06-16-2003 at 02:54 PM.

  6. #6
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Create the control with the WS_VSCROLL style set.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  7. #7
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    The project I'm working on uses a function that appends text to a text box. Might as well paste the code.

    Code:
    // textbuff is a global var containing the entire text of an edit box
    // it should be declared like:
    // char textbuff[1024];
    // 1024 is how long you want to let the buffer get.
    // This example uses information to get the HWND from a dialog
    // I used resources, so IDE_TEXT_BUFFER is a #define for the
    // text box I made in the resource editor
    
    void AppendText(char *newtext)
    {
    	strcat(textbuff, "\r\n");
    	strcat(textbuff, newtext);
    	SendDlgItemMessage(
    		hDlgChat, IDE_TEXT_BUFFER, EM_SETSEL, 0, -1);
    	SendDlgItemMessage(
    		hDlgChat, IDE_TEXT_BUFFER, EM_REPLACESEL, false, (LPARAM)textbuff);
    }
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange string behavior
    By jcafaro10 in forum C Programming
    Replies: 2
    Last Post: 04-07-2009, 07:38 PM
  2. socket message sending and receiving problem
    By black in forum C Programming
    Replies: 5
    Last Post: 01-15-2007, 04:46 AM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM