Thread: int to LPCTSTR

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

    Cool int to LPCTSTR

    Hello

    The SetDlgItemText() function takes in a LPCTSTR datatype as one of its arguments.

    I was just curious how to convert an integer into this datatype.

    Thanks in advance!

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    You could use SetDlgItemInt()

    or

    convert to a string or char array.

    Code:
    char szBuf[MAX_PATH]={0};
    _snprintf(szBuf, MAX_PATH-1,"%d",iValueToBeDisplayed);
    SetDlgItemText(hWnd, ID_EDIT,szBuf);
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Or if you're using C++ (which I assume since you cross-posted there),
    Code:
    SetDlgItemText(hWnd, ID_EDIT, boost::lexical_cast<std::string>(your_int).c_str());
    Last edited by Elysia; 07-26-2010 at 02:43 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  2. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 09:16 PM
  3. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  4. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM
  5. easy if you know how to use functions...
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 01-31-2002, 07:34 AM

Tags for this Thread