title: How to get text from CEdit control
body: <p>I'm a new guy with ATL. So forgive me to ask this question.</p>
  <p><strong>Problem description:</strong>
  One <code>CEdit</code> control is added into a ATL dialog class. It's attached in the dialog initialize function.</p>
  <pre><code>//Define the edit control
  ATLControls::CEdit  m_txtInput;
  
  //In the OnInitDialog function
  m_txtInput.Attach(GetDlgItem(IDC_INPUT_LINE));
  
  m_txtInput.SetWindowText(_T(&quot;New directory&quot;));
  
  //In the public memeber function of the dialog GetInput()
  //I have tried three kinds of method to get the text. But all of them are throw an 
  //assert exception, IsWindow() failed. 
  //1.
  GetDlgItemText(IDC_INPUT_LINE, input);
  //2.
  ZeroMemory(m_lptstrInput, MAX_PATH);
  m_txtInput.GetLine(0, m_lptstrInput, MAX_PATH);
  //3.
  BSTR input; 
  m_txtInput.GetWindowText(input);
  </code></pre>
  <p><a href="https://stackoverflow.com/questions/10662946/visual-c-get-string-from-cedit">Here</a> is a topic about how to get text from <code>CEdit</code> but it is not working.</p>
  <p>Why the <code>CEdit</code> control could be set text with the function <code>SetWindowText()</code> but can't get the text by the function <code>GetWindowText()</code>? It's really confuse me. Thanks a lot if someone could explain it for me.</p>