I searched the internet and tried the whole last night to Get Unicode Text out of an TextBox. Because I presume that many VB6 Unicoders hang here around, I ask my question in this forum.
Well, finaly I succeeded. With the following code I can take (get and send) the Unicode Text from an hwnd (TextBox1.hwnd) to another hwnd (TextBox2.hwnd).
But when I enter instead of TextBox1.hwnd the hwnd of a textbox of any foreign aplication, it doesn't get the Text. Do you have any idea?
Code: Select all
Private Declare Function GetWindowTextUnicode Lib "user32" Alias "GetWindowTextW" (ByVal hWnd As Long, ByVal lpString As Long, ByVal cch As Long) As Long
...
Dim lLen As Long
Dim sBuf As String
Dim strW As String
lLen = GetWindowTextLengthW(TextBox1.hWnd) + 1
If (lLen > 1) Then
sBuf = String$(lLen, 0)
GetWindowTextUnicode TextBox1.hWnd, StrPtr(sBuf), lLen
lLen = InStr(sBuf, vbNullChar)
If lLen > 1 Then
strW = Left$(sBuf, lLen - 1)
SendMessageUnicode TextBox2.hWnd, WM_SETTEXT, 0, StrPtr(strW)
End If
End If
I appriciate any help!