Thread: Printing a string in EDITTEXT

  1. #1
    george7378
    Guest

    Printing a string in EDITTEXT

    Hi everyone,

    I have got some experience of printing numbers in a Win32 EDITTEXT control, but I don't know how to print strings. At the moment, I am using this:

    Code:
    double number = 9.81;
    char string[100];
    sprintf_s(string,"%0.2f", number);
    SetDlgItemText(hwnd, IDC_EDITTEXT, string);
    How would I adapt this to print words instead of just numbers?

    Thanks a lot!

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Code:
    int AddString(char *text)
      { return SetDlgItemText(hDlg,IDC_EDITTEXT,text); }
    text is a string passed into the function...

    If you post the code that's giving you trouble, you'll get a lot better answers...
    Last edited by CommonTater; 11-24-2011 at 01:33 PM.

  3. #3
    george7378
    Guest
    Thanks a lot - I will try that out. That basically is all the code I have - I set the code to execute when I press a button (case IDC_BUTTON) and it displays the number in the text box. I just wanted to do the same with text, but I couldn't see how.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by george7378 View Post
    Thanks a lot - I will try that out. That basically is all the code I have - I set the code to execute when I press a button (case IDC_BUTTON) and it displays the number in the text box. I just wanted to do the same with text, but I couldn't see how.
    You should have probably taken the huge hint from line 4 of your own example... "string"...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. printing a string
    By weili in forum C Programming
    Replies: 1
    Last Post: 07-25-2011, 03:08 PM
  2. Printing String Arrays
    By kwikness in forum C Programming
    Replies: 6
    Last Post: 10-08-2007, 01:44 AM
  3. problem about edittext
    By yan in forum Windows Programming
    Replies: 1
    Last Post: 08-01-2005, 05:45 AM
  4. floating point variables in edittext controls
    By dootickle in forum Windows Programming
    Replies: 3
    Last Post: 04-15-2004, 11:15 AM
  5. printing a string
    By ktntech in forum C Programming
    Replies: 1
    Last Post: 01-24-2002, 05:09 PM