Results 1 to 3 of 3

Thread: Hard: LB_GETTEXT?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263

    Exclamation Hard: LB_GETTEXT?

    Alright, well, I have some code that will sequentially go through a list and get the test of each in another application. The code gets the right amount of items, however when it gets the text it appears to be garbled, or in code. I remember reading somewhere that you've got to use ReadProcessMemory or something... any ideas? Thanks in advance.

  2. #2
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    Talking

    This code is used to find a window with a caption
    somewhat like the string you have.

    You should be able to understand from this.

    VB Code:
    1. Option Explicit
    2. Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
    3. Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    4. Declare Function GetForegroundWindow Lib "user32.dll" () As Long
    5.  
    6. Public Const GW_HWNDNEXT = 2
    7. Public Const GW_CHILD = 5
    8.  
    9. '********************************************
    10. '*Give it part of the window text your looking for
    11. '*it will give you the hWnd
    12. '*usefull for windows that text is like "[project] - microsoft visual basic [design]"
    13. '*usage:
    14. '*Msgbox FindWindowLike("visual basic")
    15. '*Returns 0 if not found
    16. '*******************************************
    17.  
    18. Function FindWindowLike(strPartOfCaption As String) As Long
    19. Dim hWnd As Long
    20. Dim strCurrentWindowText As String
    21. Dim r As Integer
    22.  
    23. hWnd = GetForegroundWindow
    24.  
    25. Do Until hWnd = 0
    26.         strCurrentWindowText = Space$(255)
    27.         r = GetWindowText(hWnd, strCurrentWindowText, 255)
    28.         strCurrentWindowText = Left$(strCurrentWindowText, r)
    29.         'hWnd = GetWindow(hWnd, GW_CHILD)
    30.         If InStr(1, LCase(strCurrentWindowText), LCase(strPartOfCaption)) <> 0 Then GoTo Found
    31.         hWnd = GetWindow(hWnd, GW_HWNDNEXT)
    32. Loop
    33.  
    34. Exit Function
    35. Found:
    36. FindWindowLike = hWnd
    37. End Function

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263

    What?

    Maybe you didn't quite understand what I was was asking.... I meant a list as a ListBox, and the items it holds. I can get the correct amount of items, but LB_GETTEXT does not return the text, but garbled or coded information... and I know I am calling it right. I think that you have to somehow use ReadProcessMemory to get the specified information, but I don't know how to approach it.

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