DrawText() and TextOut() newbie question

This is a discussion on DrawText() and TextOut() newbie question within the Windows Programming forums, part of the Platform Specific Boards category; Hi, Newbie queston: Is there any way to use TextOut() or DrawText() to display an int? I've read the FAQ ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    1

    Question DrawText() and TextOut() newbie question

    Hi,

    Newbie queston: Is there any way to use TextOut() or DrawText() to display an int? I've read the FAQ and have noticed the int -> string casts, I need to convert/cast from int to CString, a normal cast doesn't work: 'cannot convert from 'int' to 'ATL::CStringT'.

    Thanks in advance.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Use sprintf() to write the int to a string then TextOut() the string.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,262
    If you're just displaying a single int, with no supporting text, itoa would be sufficient.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    CString offers the ::Format() function which works like sprintf

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing using DrawText() or TextOut()
    By Eversman in forum Windows Programming
    Replies: 1
    Last Post: 05-24-2004, 12:12 PM
  2. DrawText and backgrounds c++
    By AtomRiot in forum Windows Programming
    Replies: 1
    Last Post: 01-04-2003, 02:10 AM

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