Results 1 to 4 of 4

Thread: getting text from editbox

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    getting text from editbox

    Code:
    char *buf[20];
    	SendMessage(editbx,EM_GETLINE,0,buf);
    	MessageBox(NULL,buf, "Interest App", MB_OK | MB_ICONINFORMATION);
    im trying to retrieve text from a editox called "editbx" and display it in a messagebox. Anyone know how to. I looked it up on MSDN and it was a bit confusing
    Matt

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    If you are using a dialogue then you can use this:
    Code:
    GetDlgItemText
    The GetDlgItemText function retrieves the title or text associated with a control in a dialog box. 
    
    UINT GetDlgItemText(
      HWND hDlg,       // handle of dialog box
      int nIDDlgItem,  // identifier of control
      LPTSTR lpString, // address of buffer for text
      int nMaxCount    // maximum size of string
    );
     
    Parameters
    hDlg 
    Identifies the dialog box that contains the control. 
    nIDDlgItem 
    Specifies the identifier of the control whose title or text is to be retrieved. 
    lpString 
    Pointer to the buffer to receive the title or text. 
    nMaxCount 
    Specifies the maximum length, in characters, of the string to be copied to the buffer pointed to by lpString. If the length of the string exceeds the limit, the string is truncated. 
    Return Values
    If the function succeeds, the return value specifies the number of characters copied to the buffer, not including the terminating null character.
    
    If the function fails, the return value is zero. To get extended error information, callGetLastError.
    
    Remarks
    The GetDlgItemText function sends a WM_GETTEXT message to the control.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    If not then:
    Code:
    long fl  =SendMessage(secdlge,WM_GETTEXTLENGTH,0,0);
    fl++;
    TCHAR *ft = new TCHAR[fl];
    SendMessage(secdlge,WM_GETTEXT,fl,(LPARAM)ft);
    //ft contains text
    MessageBox(NULL,ft, "Interest App", MB_OK | MB_ICONINFORMATION);
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You can also use GetWindowText if you're using a window:
    Code:
    int iLen = GetWindowTextLength(hWnd_Edit);
    TCHAR *pcBuf = new TCHAR[iLen + 1];
    GetWindowText(hWnd_Edit, pcBuf, iLen);
    
    // Use pcBuf
    
    delete[] pcBuf;
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width