Thread: DrawText() and TextOut() newbie question

  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,829
    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,273
    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,793
    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, 03:10 AM