Results 1 to 5 of 5

Thread: Is there any way to determine the contents of another window?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    London UK
    Posts
    671

    Is there any way to determine the contents of another window?

    I am still trying to find a way to programmatically get the text out of a window similar to the one shown in the attached screen shot.

    The Text I am interested in is from the "Supplier Letter Fields" header through to the "Custom Fields" footer.

    This all seems to be in one child window with the following details:

    Class = AfxWnd42
    Style = &H52000000
    Handle = &H706EE
    ID = &H0

    Using the GetWindowText API for this window returns a zero length string

    What other approach can I take to programmatically retrieve this info?

    Thanks in advance for any assistance.
    Attached Images Attached Images  

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Use SendMessasge API with WM_GETTEXT.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    London UK
    Posts
    671
    Hi Serge,

    Thank you for your response. I have tried the following code

    VB Code:
    1. Private Const WM_GETTEXT = &HD
    2. Private Const WM_GETTEXTLENGTH = &HE
    3. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    4. Private Function GetText(WindowHandle As Long) As String
    5. Dim TextReturned As String
    6. Dim slength As Long
    7. Dim retval As Long
    8. slength = SendMessage(WindowHandle, WM_GETTEXTLENGTH, ByVal CLng(0), ByVal CLng(0)) + 1
    9. TextReturned = Space(slength)
    10. retval = SendMessage(WindowHandle, WM_GETTEXT, ByVal slength, ByVal TextReturned)
    11. GetText = Left(TextReturned, retval)
    12. End Function
    13.  
    14. Private Sub Form_Load()
    15. Debug.Print "Returned text is: "; GetText(&H706EE )
    16. End Sub

    but this too is returning the result that GetText(&H706EE ) = "".

    Any ideas as to why this may be the case?

    (I am getting the hwnd for the controls on the Form from the code at http://support.microsoft.com/support.../Q112/6/49.asp )

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Are you sure you got a valid hWnd of the control ???

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    London UK
    Posts
    671
    Yes I was wondering that too!

    But I have now found some code to enumerate all windows and controls at

    http://support.microsoft.com/support.../q183/0/09.asp

    and the information I am looking for doesn't seem to be retrievable through the GetWindowText API
    (as it did not appear in any of the 30,000 or so windows that it found)!

    I am not actually sure whether what I want to do is possible.
    By way of comparison if I view a Microsoft Word Document then I can determine that the main document body is in a control of class
    _WwG, and currently has a handle of &H70506
    Yet despite the document containing visible text the GetWindowText function returns "".

    As you may have gathered my understanding of this whole area is pretty poor so any help would be gratefully received!

    Thanks a lot for your time.

    Martin
    Last edited by MartinSmith; Aug 31st, 2001 at 06:24 AM.

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