Printing a string in EDITTEXT

This is a discussion on Printing a string in EDITTEXT within the Windows Programming forums, part of the Platform Specific Boards category; Hi everyone, I have got some experience of printing numbers in a Win32 EDITTEXT control, but I don't know how ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    128

    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
    Registered User
    Join Date
    Feb 2010
    Posts
    128
    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, 04:08 PM
  2. Printing String Arrays
    By kwikness in forum C Programming
    Replies: 6
    Last Post: 10-08-2007, 02:44 AM
  3. problem about edittext
    By yan in forum Windows Programming
    Replies: 1
    Last Post: 08-01-2005, 06:45 AM
  4. floating point variables in edittext controls
    By dootickle in forum Windows Programming
    Replies: 3
    Last Post: 04-15-2004, 12:15 PM
  5. printing a string
    By ktntech in forum C Programming
    Replies: 1
    Last Post: 01-24-2002, 05:09 PM

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