int to LPCTSTR

This is a discussion on int to LPCTSTR within the Windows Programming forums, part of the Platform Specific Boards category; Hello The SetDlgItemText() function takes in a LPCTSTR datatype as one of its arguments. I was just curious how to ...

  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,859
    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
    Posts
    22,985
    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 03: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, 09:55 AM
  2. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 10: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


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