Thread: CEdit to CString to String

  1. #1
    Registered User
    Join Date
    Jan 2006

    CEdit to CString to String

    I'm trying to convert a variables entered in as a CEdit to a CString, doing some standard error checking, then later to a string to pass to another api. Does anyone know the functions to do this?

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Banks of the River Styx
    Have you tried MSDN? Looks like the GetLine member might help, but it doesn't take a CString. You might have to allocate a regular character buffer and construct a CString off that...
    (Disclaimer: Never used MFC. )
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Registered User
    Join Date
    Jan 2006
    I'm trying to basically just get the input down to a string to throw into a networking api.
    I know how to convert a CString to a String:

    CString cs("Hello");
    std::string s((LPCTSTR)cs);
    but this CEdit box is killing me.

  4. #4
    I am me, who else?
    Join Date
    Oct 2002
    Wow that was stupid I totally missed the question...

    Yeah you use GetDlgItemText( CString, Control ID )

    Sorry that was a totally unhelpful answer before...
    Last edited by dpro; 01-18-2006 at 07:24 PM.

  5. #5
    train spotter
    Join Date
    Aug 2001
    near a computer
    GetDlgItemText() takes a CString.



    CEdit SomeEdit;
    CString String;

    Last edited by novacain; 01-18-2006 at 07:03 PM.
    "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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  3. Problems with my custom string class
    By cunnus88 in forum C++ Programming
    Replies: 15
    Last Post: 11-15-2005, 08:21 PM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM