Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8016139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:27:38+00:00 2026-06-04T20:27:38+00:00

This old stackoverflow post is asking pretty much the same question that I have,

  • 0

This old stackoverflow post is asking pretty much the same question that I have, however using Spy++ I have obtained the controls handle ID. Now what? 🙂

I am not sure what this process is called where I can obtain the contents of another applications control from a .net application, therefore I am not having much success with results on the old google machine.

I have an MFC application with a listbox that contains data I need to automate a task using a WPF C# application. I would prefer not to use an external lib and don’t think it would be too labour intensive once I have found the process and have my C# app take visibility of the respective list control to do what I need.

Can anyone please point me in the right direction as to what I should be looking up or provide some code to get me started. At this point I’m stuck and my little project relies pretty heavily on this. I don’t want to use an OCR either.

Thanks,

Ash

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:27:39+00:00Added an answer on June 4, 2026 at 8:27 pm

    To get text from Win32 ListBox control you have to use messages and functions specially for that control, here is a reference :

    http://msdn.microsoft.com/en-us/library/windows/desktop/ff485971%28v=vs.85%29.aspx

    In your case you should first see how many items are in the listbox with LB_GETCOUNT, and then for each item get text with LB_GETTEXT.

    Here is the method that will return items in a list, parameter is ListBox control window handle :

    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
    static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, StringBuilder lParam); 
    const int LB_GETCOUNT = 0x018B;
    const int LB_GETTEXT = 0x0189;
    
    private List<string> GetListBoxContents(IntPtr listBoxHwnd)
    {
      int cnt = (int)SendMessage(listBoxHwnd, LB_GETCOUNT, IntPtr.Zero, null);
      List<string> listBoxContent = new List<string>();
      for (int i = 0; i < cnt; i++)
      {
        StringBuilder sb = new StringBuilder(256);
        IntPtr getText = SendMessage(listBoxHwnd, LB_GETTEXT, (IntPtr)i, sb);
        listBoxContent.Add(sb.ToString());
      }
      return listBoxContent;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some code kicking around that uses this old internal Sun package for
I've noticed that some sites (including the old http://careers.stackoverflow.com 1.0) have query strings that
I have this old Access database (2000 format) which i want to convert to
I found this similar question here , but this is really old. Was it
This is an age old problem - but now I'm using scriptaculous its come
This morning we found an old chunk of code that was causing a library
Dear stackoveflow, I have this problem. I'm working with an old version of mssql
Content people have been using Word and pasting things into the old unicode system.
I think this question is very usual. Many results on Stackoverflow has said about
I was reading this thread/post: https://stackoverflow.com/questions/262298/windows-c-ui-technology and am also wondering about a non .NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.