Thread: ADDING text to a STATIC control

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    ADDING text to a STATIC control

    I have a static control, and when the user does something, I want to ADD text to it. I don't think I can use the set text function, because I do want to keep the text that is already there. I just want to append text to what is already in the static.

    How would I do this?

    Thanks!
    1978 Silver Anniversary Corvette

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Use GetWindowText to retrieve the current text into a suitable buffer, concatenate your additional string and then use SetWindowText to put the concatenated string into the static control. Unfortunately there is no single api function for adding a string to the contents of a static control.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Someone posted this code on the board and I really like it. It is designed for an edit box (which may be made static) however. I have made my own mod to it.

    Code:
    void PostText (HWND hwnd, char *string)
    {
    int ndx;
    ndx = GetWindowTextLength (hwnd);
    SendMessage (hwnd, EM_SETSEL, (WPARAM)ndx, (LPARAM) ndx);
    SendMessage (hwnd, EM_REPLACESEL, 0, (LPARAM) (LPCTSTR) string);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LNK2001 ERROR!!! need help
    By lifeafterdeath in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2008, 05:05 PM
  2. Static control color change
    By Devil Panther in forum Windows Programming
    Replies: 6
    Last Post: 08-10-2005, 09:36 AM
  3. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  4. Updating Static Control Color Real-Time :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-29-2002, 03:09 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM