PDA

Click to See Complete Forum and Search --> : Need help from API wizards


terebi
Aug 29th, 2000, 05:29 PM
Hi,

I was wondering if anybody knows how to retrieve text from a textbox that is not in my process.
I am able to get the hwnd and CtrlID but are unable to retrieve the text. I thought maybe a sendmessage passing WM_GETTEXT would work, but unfortunately, it so happens that, windows require I pass a pointer to a string, as its lparam, or was it wparam???
When I tried using just a string, I got a kernell32 error, crashing VB.

gfrench
Aug 29th, 2000, 05:44 PM
If you found out about WM_GETTEXT, i assume you are familiar with either API Viewer of MSDN Library. You can use the GetWindowText API call if you have the handle to the window, you can look this up, or if my assumptions are incorrect, contact me and i will help you out a bit more. It is a pretty straight forward api call.

Hope this helps

terebi
Aug 31st, 2000, 05:33 AM
Hi,

I know how to get the handler to the textbox, but when I use WM_GETTEXT, Windows requires that I pass a pointer to a string. What I did was pass a normal string, that had been filled using the method Space(255). When I displayed the contents I got a weird set of ascii???
I tried the alternative getdlgitemtxt, but thi function does not work on text boxes, like the one in microsoft word. Any suggestions?, or do I have to use C++ for this.

Aug 31st, 2000, 04:41 PM
Use GetWindowText

Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Private Sub Command1_Click()
Dim sName As String * 255
Dim iLength As Integer

iLength = GetWindowText(MyHwnd, sName, 255)
MsgBox Left(sName, iLength)
End Sub