Why the painful way? Just sendmessage with WM_GETTEXT and grab it all into a
buffer in one go.
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
Please reply to the newsgroups so all can participate.
"Jay Taplin" <jt*****@integraware.com> wrote in message
news:zzVyf.6001$2x4.3941@trndny05...
: Here is a routine to do it. It is a modified version of what can be found
: at
http://www.freevbcode.com/ShowCode.asp?ID=2493
:
: Public Function GetTextBoxLine(hWnd As Long) As String
: 'INPUT: hWnd = Handle to text box
: 'OUTPUT: Text of specified TextBox Control
:
: Dim lngLineCount As Long
: Dim lngLineNumber As Long
: Dim lngRet As Long
: Dim lngLen As Long
: Dim lngFirstCharPos As Long
: Dim bytBuffer() As Byte
: Dim strAns As String
:
: 'get number of lines
: lngLineCount = SendMessage(hWnd, EM_GETLINECOUNT, 0, 0&)
:
: For lngLineNumber = 0 To lngLineCount - 1
: 'first character position of the line
: lngFirstCharPos = SendMessage(hWnd, EM_LINEINDEX, lngLineNumber,
0&)
:
: 'length of line
: lngLen = SendMessage(hWnd, EM_LINELENGTH, lngFirstCharPos, 0&)
:
: ReDim bytBuffer(lngLen) As Byte
:
: bytBuffer(0) = lngLen
:
: 'text of line saved to bytBuffer
: lngRet = SendMessage(hWnd, EM_GETLINE, lngLineNumber, bytBuffer(0))
:
: If lngRet Then
: strAns = strAns & Left$(StrConv(bytBuffer, vbUnicode), lngLen)
: End If
: Next
:
: GetTextBoxLine = strAns
: End Function
:
: You can call it by GetTextBoxLine([hWnd of Control])
:
: Jay Taplin MCP
: "Apach" <ne**@aha.com> wrote in message news:dq**********@bagan.srce.hr...
: > Hellou!
: >
: > Please can anybody tell me how to Get text from edit box in some window
: > (etc. notepad) if i have HWND of this edit box.
: >
: > I try by using GetWindowText API butt this API return text only if this
: > text is caption of some window in title bar.
: >
: > Thanks!
: >
:
: