Results 1 to 4 of 4

Thread: WM_GETTEXT missing 1 charecter

  1. #1

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720

    WM_GETTEXT missing 1 charecter

    I am trying to get the text of an AIM conversation, It seems to get everything but the end is always </HTML missing the > part. What is wrong with this?

    VB Code:
    1. Private Sub Command2_Click()
    2.     Dim hWndx As Long, kLENGTH As Long
    3.     Dim temp As String, ok As Long
    4.    
    5.     hWndx = 918780 '2360364
    6.     kLENGTH = SendMessage(hWndx, WM_GETTEXTLENGTH, ByVal 0&, ByVal 0&) + 1
    7.     temp = Space(kLENGTH)
    8.     ok = SendMessage(hWndx, WM_GETTEXT, ByVal kLENGTH, ByVal temp)
    9.     Text1.Text = temp
    10.     MsgBox "Length: " & kLENGTH & " But we got: " & Len(Text1.Text)
    11.    
    12.     'Open "C:\TEMP.html" For Output As #1
    13.         'Print #1, temp
    14.     'Close #1
    15. End Sub
    asdf

  2. #2
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    API functions normally need C-style strings. Usually you have to provide them a buffer, in which you can store the desired content. In C strings are arrays of characters, which are always terminated by a 0-character. (byte with value 0.) Probably you have to take that into account in your buffer, so you have to create the buffer one byte larger:

    VB Code:
    1. temp = Space(kLENGTH + 1)

    I hope this will help.

  3. #3

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720
    hmm, I know about the C style 0 terminating thing, but I thought I fixed that with this line

    kLENGTH = SendMessage(hWndx, WM_GETTEXTLENGTH, ByVal 0&, ByVal 0&) + 1

    the +1 at the end is the same as temp = Space(kLENGTH + 1) isnt it? also I can get the text of another textbox just fine, like IE URL bar or w/e but it doesnt work on AIM window.
    asdf

  4. #4
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    Sorry, I missed the + 1 at the end of that line.
    I have no other suggestion for now.

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