Results 1 to 3 of 3

Thread: Help using SendMessage() & WM_GETTEXT

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    36

    Help using SendMessage() & WM_GETTEXT

    I am having some problems understanding and implementing WM_GETTEXT.

    I am writing an application in which I need to get the text from a RichEdit text box in another running windows application. Through research I have come to the conclusion that I need to use WM_GETTEXT, yet I am having some difficulty.

    The first problem I am running into is figureing out the hwnd of the window that contains the text box that I need to pull data from. In the task manager the title is "Picnic 12945 - Play online". I also downloaded winspecter that lets me see the hwnd of the window, but I cant figure out how to find this dynamically. To add additional complexity to the problem there are multiple picnics that I could be accessing from time to time.

    The second problem is if I am able to find this hwnd then I am unsure as to how to access the individual control (text box) in that window.

    I have spent many hours searching forums and google for a soultion. If you could offer some help it would be greatly apprecaited.

    Thank you,
    -Patrick

  2. #2

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    36
    I am still stumped on the WM_GETTEXT method. I have recieved the handles of the application and of the RICHEDIT control but the gettext dosent return anything. Here is the code of what I have tried.

    Code:
     
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim dvhwnd As Integer = FindWindowEx(myHandle, 0, "RICHEDIT", "")
            Dim TxtLen As Integer
            Dim txt As String
            Dim txtFinal As String
            Dim txtFinal2 As String
    
            TxtLen = SendMessage(dvhwnd, WM_GETTEXTLENGTH, 0, 0)
            txtFinal2 = SendMessage(dvhwnd, WM_GETTEXT, TxtLen + 1, TxtLen)
            txtFinal = Trim(txt)
            MessageBox.Show("TextLen =" & TxtLen)
            MessageBox.Show("txt:" & txt)
            MessageBox.Show("txtFinal:" & txtFinal)
            MessageBox.Show("txtFinal2:" & txtFinal2)
    
            lbl3.Text = myHandle
    
        End Sub
    THanks,
    Patrick

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    36
    Solved.

    Thanks for the help

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