SendMessage cannot receive text using WM_GETTEXT

I am trying to get the text of a window with the SendMessage function. However, I can get the text length, but I cannot get the text. I think the txt (String) type is wrong for SendMessage. Thank.

Const WM_SETTEXT = &HC
Const WM_GETTEXT = &HD
Const WM_GETTEXTLENGTH = &HE

Dim hwnd As Long
Dim hwnd_child As Long
Dim result As Long
Dim txtlen As Long
Dim txt As String


hwnd = FindWindow(vbNullString, "İngilizce Türkçe Sözlük")
hwnd_child = FindWindowEx(hwnd, 0, "Edit", vbNullString)
txtlen = SendMessage(hwnd_child, WM_GETTEXTLENGTH, 0, 0)
s = Space$(txtlen + 1)
result2 = SendMessage(hwnd_child, WM_GETTEXT, ByVal txtlen, txt) 
MsgBox txt

      

+3


source to share





All Articles