Results 1 to 4 of 4

Thread: Need help from API wizards

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    15

    Cool

    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.

  2. #2
    Member
    Join Date
    Aug 2000
    Posts
    60

    Cool

    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
    Grant French
    -----------------------------------------------
    E-Mail: [email protected]
    ICQ: 33122184

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    15
    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.

  4. #4
    Guest
    Use GetWindowText
    Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width