Results 1 to 7 of 7

Thread: text from a message box

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870

    text from a message box

    I have a trading program running on my computer.

    When a trade goes through a message box appears with details of the trade in a list box. Is it possible to get this information out of the list box?

    Thanks
    Nick

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    It has a list box on it so it is not a standard messagebox. Get the handle of the list box and retrieve the text by sending the LB_GETTEXT message:
    Code:
    LB_GETTEXT
    An application sends an LB_GETTEXT message to retrieve a string from a list box. 
    
    LB_GETTEXT 
    wParam = (WPARAM) index;                // item index 
    lParam = (LPARAM) (LPCTSTR) lpszBuffer; // address of buffer 
     
    Parameters
    index 
    Value of wParam. Specifies the zero-based index of the string to retrieve. 
    Windows 95 and Windows 98: The wParam parameter is limited to 16-bit values. This means list boxes cannot contain more than 32,767 items. Although the number of items is restricted, the total size in bytes of the items in a list box is limited only by available memory. 
    
    lpszBuffer 
    Value of lParam. Pointer to the buffer that will receive the string. The buffer must have sufficient space for the string and a terminating null character. An LB_GETTEXTLEN message can be sent before the LB_GETTEXT message to retrieve the length, in characters, of the string. 
    Return Values
    The return value is the length of the string, in characters, excluding the terminating null character. If index does not specify a valid index, the return value is LB_ERR.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    thanks,

    how do I find out the ID of the box, and the handle of the listbox?

    Thanks
    Nick

  4. #4
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    I'm assuming you didn't write this app, in which case you will need to use FindWindowEx to search for the app, then search again on all the child windows of the app to find the one you want, then use Vlatko's method...
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Code:
    Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    
    · hwndParent
    Identifies the parent window whose child windows are to be searched.
    If hwndParent is NULL, the function uses the desktop window as the parent window. The function searches among windows that are child windows of the desktop.
    
    · hwndChildAfter
    Identifies a child window. The search begins with the next child window in the Z order. hwndChildAfter must be a direct child window of hwndParent, not just a descendant window.
    If hwndChildAfter is NULL, the search begins with the first child window of hwndParent.
    Note that if both hwndParent and hwndChildAfter are NULL, the function searches all top-level windows.
    
    · lpszClass
    Points to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpszClass; the high-order word must be zero.
    
    · lpszWindow
    Points to a null-terminated string that specifies the window name (the window’s title). If this parameter is NULL, all window names match.
    Code:
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    · lpClassName
    Points to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpClassName; the high-order word must be zero.
    
    · lpWindowName
    Points to a null-terminated string that specifies the window name (the window’s title). If this parameter is NULL, all window names match.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  6. #6
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Something like this:
    Code:
    Dim hnd as Long, lbhnd as Long
    hnd = FindWindow(vbNullString,msgboxtitle)
    lbhnd = FindWindowEx(hnd,vbNullString,LISTBOX,vbNullString)\
    'lbhnd is the handle of the listbox
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  7. #7
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    cheers Vlatko, I couldn't find any sample code anywhere (honest...)
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

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