ERRO AO DECLARAR FUNCAO

GRAEFF 28/10/2009 18:43:10
#326470
Galera alguem pode ajudar, meu programa nao ta capturando nenhum texto da janela!! Era pra capturar tudo que era digitado em uma sala de chat

Segue o codigo!!


Private Declare Function FindWindowA Lib [Ô]user32[Ô] (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowExA Lib [Ô]user32[Ô] (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowTextLengthA Lib [Ô]user32[Ô] (ByVal hWnd As Long) As Integer
Private Declare Function GetWindowTextA Lib [Ô]user32[Ô] (ByVal hWnd As Long, ByVal lpString As String, ByVal nMaxCount As Integer) As Integer

Sub DisplayWindowText(): nhWnd = GetMyWindow: nTextLength = GetWindowTextLengthA(nhWnd)
szBuffer = Space(nTextLength + 1): nLength = GetWindowTextA(nhWnd, szBuffer, nTextLength + 1)
szBuffer = Left(szBuffer, nLength): Text1.Text = szBuffer: End Sub


Function GetMyWindow() As Long
Dim lParent As Long
Dim lChild(1 To 6) As Long
lParent = FindWindowA([Ô]TMainForm[Ô], [Ô]Janela do chat[Ô])
lChild(1) = FindWindowExA(lParent, 0, [Ô]MDIClient[Ô], [Ô][Ô])
lChild(2) = FindWindowExA(lChild(1), 0, [Ô]TfrmChatChannel[Ô], [Ô]sala do chat[Ô])
lChild(3) = FindWindowExA(lChild(2), 0, [Ô]TPanel[Ô], [Ô][Ô])
lChild(4) = FindWindowExA(lChild(3), 0, [Ô]TPanel[Ô], [Ô][Ô])
lChild(5) = FindWindowExA(lChild(4), 0, [Ô]TPanel[Ô], [Ô][Ô])
lChild(6) = FindWindowExA(lChild(5), 0, [Ô]TRichEdit98[Ô], [Ô][Ô])
GetMyWindow = lChild(6)
End Function

Private Sub Command1_Click()
DisplayWindowText
End Sub
GRAEFF 29/10/2009 10:23:49
#326500
Problema resolvido!!
EDERMIR 29/10/2009 10:48:37
#326503
Mostre a solução e feche o tópico.
GRAEFF 29/10/2009 10:55:22
#326505
Solução!

Private Declare Function SendMessageA Lib [Ô]user32[Ô] (ByVal hWnd As Long, ByVal Msg As Long, wParam As Any, lParam As Any) As Long
Private Declare Function FindWindowA Lib [Ô]user32[Ô] (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowExA Lib [Ô]user32[Ô] (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Sub GetText()
Dim nTextLength As Long, szBuffer As String, lParent As Long, lChild(1 To 6) As Long
lParent = FindWindowA([Ô]TMainForm[Ô], [Ô]texto da janela[Ô])
lChild(1) = FindWindowExA(lParent, 0, [Ô]MDIClient[Ô], [Ô][Ô])
lChild(2) = FindWindowExA(lChild(1), 0, [Ô]TfrmChatChannel[Ô], [Ô]texto da janela do chat[Ô])
lChild(6) = FindWindowExA(lChild(5), 0, [Ô]TRichEdit98[Ô], [Ô][Ô])
nTextLength = SendMessageA(lChild(6), &HE, ByVal 0, ByVal 0) + 1
szBuffer = Space(nTextLength - 1)
SendMessageA lChild(6), &HD, ByVal nTextLength, ByVal szBuffer
Text1.Text = szBuffer
End Sub
Private Sub Command1_Click()
GetText
End Sub
Tópico encerrado , respostas não são mais permitidas