Getting a string from an Edit Box

This is a discussion on Getting a string from an Edit Box within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to get a string with this function: GetDlgItemText(hWnd, IDC_SECTIONTYPE, buffer, sizeof(buffer) / sizeof(TCHAR)); sectionType = _tcstod(buffer, &pEnd); But ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    20

    Post Getting a string from an Edit Box

    I'm trying to get a string with this function:
    GetDlgItemText(hWnd, IDC_SECTIONTYPE, buffer, sizeof(buffer) / sizeof(TCHAR));
    sectionType = _tcstod(buffer, &pEnd);


    But it doesn't work!

    Is there other function for this?

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    I think the size you are sending is wrong.

    If you have declared

    buffer[64]="\0";

    then

    GetDlgItemText(hWnd,IDC_EDITCONTL,Buffer,64);

    GetDlgItemText is asking for the MAX storage space it can use, not how much of the buffer is used before you send it in.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    20
    It compile but does not output, I'm using this:

    wsprintf( string, "%s", SectionType );
    SetDlgItemText(hWnd,IDC_OUTPUT,string);

    Is this wrong?

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Could be the

    wsprintf

    Try sprintf instead (same format, just remove the w from wsprintf).

    Check that you have the text in the string, use a messagebox or debugger to watch.
    ie
    MessageBox(NULL,string,"Debug",MB_OK);
    (If you have the HWND use that instead of the NULL)

    Look at the return from SetDlgItemText and use GetLastError() if failing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  2. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 07:00 PM
  3. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 10:06 PM
  4. Limiting Characters in Edit Box :: MFC
    By kuphryn in forum Windows Programming
    Replies: 5
    Last Post: 06-02-2002, 10:21 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

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