title: VB.NET - GetWindowText() returns ZERO for "edit" class
body: <p>I am trying to retreive text from another application by app's control handle. I have no problem if control is "static" but my code seems not working for "edit" control. As MSDN says, GetWindowText cannot retreive text from EDIT control but maybe you know another way of achieving this?</p>
  
  <p>My current code is here:</p>
  
  <pre><code>Dim newHwnd As IntPtr = Handler.GetClassByPosition(ParentHwnd, cls, classPosition)
      Dim length As Integer = Handler.GetWindowTextLength(newHwnd)
      Dim sb As New String(" ".Chars(0), length + 1)
      If cls = "edit" Then
          Handler.GetWindowText(newHwnd, sb, sb.Length)
      End If
  </code></pre>
  
  <p>where GetClassByPosition returns control's handle by specifying parent handle, class name (static,edit or button) and classPosition (used in loop - not important for now)</p>
  
  <p>As I said, it works great with STATIC (labels etc) but it returns 0 if I'm retreiving text from EDIT (textbox) control of that external application.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I have tried the following solution which success in returning data if data is integer but if it contains any letter, result is 0:</p>
  
  <pre><code>Dim tmpstr As IntPtr = Marshal.AllocHGlobal(100)
          Dim NumText = API.SendMessage(Hwnd, API.WM_GETTEXT, 200, tmpstr )
          NumText = Marshal.PtrToStringAnsi(tmpstr )
          Return NumText
  </code></pre>
  
  <p>Thanks in advance,
  Nikola</p>