SetWindowText()

This is a discussion on SetWindowText() within the Windows Programming forums, part of the Platform Specific Boards category; My goal is to display a dollar amount in a static text box using the SetWindowText function. Unless there is ...

  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.
    benforbes@optusnet.com.au
    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
    University of Waterloo
    Posts
    1,903
    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().
    benforbes@optusnet.com.au
    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, 12: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, 01: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, 02:26 AM

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