CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2005
    Posts
    95

    How to retrieve a name associated with Edit Box

    Hello,

    I want to know how you can retrieve a name associated with Edit Box.

    I did some research and found the function getDlgItemText() but don;t
    know how to use it.


    Thanks.

  2. #2
    Join Date
    May 2004
    Location
    Michigan, United States
    Posts
    457

    Re: How to retrieve a name associated with Edit Box

    If hDlg is a handle to your dialog and IDC_EDIT1 is the identifier of your edit control (textbox), then this code should work:
    Code:
    // Create a buffer to hold the text...
    TCHAR szText[64];
    
    // Call the function to retrieve the text from the edit control...
    GetDlgItemText(hDlg, IDC_EDIT1, szText, sizeof(szText));
    If you want to get fancier, you can use WM_GETTEXTLENGTH to retrieve the length of the text stored in the edit control and then dynamically create a buffer of this size ( + 1 for the terminating NULL character ) to store the result.
    Last edited by Bond; June 21st, 2005 at 01:24 PM.
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

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

Featured