Thread: I need to read a Listbox in another app

  1. #1

    Exclamation I need to read a Listbox in another app

    Please help I've been stuck on this for 6 months.

    I am trying to read data from another application. I read the microsoft tutorial on msdn about FIndwindow and GetText. That does not work for a Listbox.

    I then moved on to a hook, but my system locks up the minute I start hooking all the messages.

    I know this is possible because I can see all the data using Spy++. If it can do it I should be able to do. If anyone can give me some assistance hear it would be greatly appreciated.

    Best Regards,


  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Not too difficult.......Here's an idea that should work...

    Use Spy++ to find the class of the main window holding the list box.....

    Use FindWindow() to get a handle to than main window.......

    Now you need to scope out how the window is put together.....A listbox is a child control.......but that's not to say there arent other child windows between the main window and the listbox....ala;


    Spy++ will give up this info and the respective classes & titles without too much bother....

    Now for each child window call FindWindowEx() to get the child window....move up the z order untill you reach the ListBox you wish to use........

    Once you have the HWND you need, use it with the SendMessage() API anf th LB_ messages to play with the listbox and pilfer the info you need....

  3. #3
    Thanks. I just ran across a VB posting that was sending me down this same track. This looks like a much easier method than the one I was going for.

    Thanks for the quick reply. I'm off to give it a shot.

  4. #4
    Here is what I have so far. (just created a new app to test with).

    void CReadlbView::OnDraw(CDC* pDC)
    	CReadlbDoc* pDoc = GetDocument();
    	// TODO: add draw code for native data here
    	HWND ChildWnd,Wnd;
    	CWnd *pParentWnd = FindWindow( "Afx:400000:b:146e:6:35cf",NULL);
    		ChildWnd = FindWindowEx( pParentWnd->m_hWnd,NULL,"#32770",NULL);
    		pDC->TextOut(1,1,"Parent Window not found!");
    	if( ChildWnd )
    		Wnd = FindWindowEx( ChildWnd , NULL, "ListBox", NULL);
    	CListBox myWnd;
    //	pDC->TextOut(1,1,myWnd.SendMessage(LB_GETTEXT));
    However, the SendMessage fails because it fails the assert:

    { ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, LB_GETCURSEL, 0, 0); }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "sorting news" assignment
    By prljavibluzer in forum C Programming
    Replies: 7
    Last Post: 02-06-2008, 06:45 AM
  2. How to cast a ListBox item to an int for a switch statment?
    By Swaine777 in forum C++ Programming
    Replies: 8
    Last Post: 09-26-2004, 08:52 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Getting FULL filename from listbox
    By Garfield in forum Windows Programming
    Replies: 8
    Last Post: 01-27-2002, 08:28 AM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM