Thread: SetWindowText()

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    26

    SetWindowText()

    My goal is to display a dollar amount in a static text box using the SetWindowText function. Unless there is a better function to use. My amount field is defined as a double but the SetWindowText only excepts char's or stings. I am looking for the correct conversion method for a double to a string for C++. I also need to show the decimal and dollar sign in the amount field.


    Is there a different SetWindow function that excepts doubles?


    Thanks,

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    SetWindowText() only accepts strings, and there are no other functions to use. What you can do is printf() to a string, then use SetWindowText(). I'm not sure about a C++ method, but printf() works for me.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    26
    Thanks,

    After searching around some more I found

    sprintf(ansMonths,"$ %.2f",monthlyFee);

    Where ansMonths = char ansMonths[10];
    and monthlyFee = double monthlyFee = 24.55;

    When ansMonths is displayed in the text box I see $ 24.55

    Thanks for your help

  4. #4
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    SetDlgItemInt(HWND hDlg, int nIDDlgItem, UINT uValue, BOOL bSigned);

    sets value to the item.......easier to do it this way unless you need to have text in there.........then sprintf and setwindow would be best

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    What you can do is printf() to a string,
    Oops I meant sprintf().
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SetWindowText()
    By jay kay in forum Windows Programming
    Replies: 1
    Last Post: 03-14-2005, 01:40 PM
  2. SetWindowText(...) in richedit controls
    By jimmy_anttila in forum Windows Programming
    Replies: 8
    Last Post: 05-21-2004, 01:57 PM
  3. SetWindowText();
    By psychopath in forum Windows Programming
    Replies: 3
    Last Post: 04-04-2004, 02:56 AM
  4. SetWindowText Error ;(
    By NickName-Here in forum Windows Programming
    Replies: 8
    Last Post: 07-19-2003, 06:17 PM
  5. SetWindowText
    By Thantos in forum Windows Programming
    Replies: 7
    Last Post: 12-10-2001, 03:26 AM