title: Get item names from a .NET applications list control using winapi or mfc
body: <p>So basically i have this software which outputs data in a list form. Thanks to the comments here we have understood that it is most likely written in .NET.</p>
  
  <p>I want to scan the list so i can do some algorithms on the data. </p>
  
  <p>Using Spy++ i found that what holds this list is titled "Panel2" and i can get the handle to this (its class is "WindowsForms10.Window.8.app") using EnumChildWindows.</p>
  
  <p>However i don't know how to get to the list itself so i can read its items. I have tried EnumChildWindows on the "Panel2" handle and outputting the caption of all those windows but they are all empty.</p>
  
  <p>Can panel2 be the actuall list? If so could i just cast it to (CListCtrl*) ?</p>
  
  <p>Axilles mentions in the comments that it probably is written in .NET, wold it be possible to get the controlID / handle to the list using something like <a href="http://reflector.red-gate.com/download.aspx?TreatAsUpdate=1" rel="noreferrer">http://reflector.red-gate.com/download.aspx?TreatAsUpdate=1</a> ?</p>
  
  <pre><code>   CWnd* mainWindow;
      CWnd* panel;
      CListCtrl* list;
  
  
  
  BOOL CALLBACK findWindow( HWND hwnd,LPARAM lParam)
  {
      char text[8];
      GetWindowText(hwnd,text,8);
  
      if(strcmp(text,"Fetcher") == 0)
      {
          mainWindow= CWnd::FromHandle(hwnd);
  
          return false;
      }
  
      return true;
  }
  
  BOOL CALLBACK findPanel(HWND hwnd,LPARAM lParam)
  {
  
      char text[7];
      GetWindowText(hwnd,text,7);
  
      if(strcmp(text,"Panel2") == 0)
      {
          panel = CWnd::FromHandle(hwnd);
  
          return false;
      }
  
      return true;
  }
  
  
  void CAnalyzeDlg::OnBnClickedButton1()
  {
      mainWindow = 0;
  
      while(mainWindow == 0)
      {
      ::EnumWindows(findWindow,0);
      }
  
      mainWindow -&gt;ActivateTopParent();
  
      while(panel == 0) ::EnumChildWindows(mainWindow -&gt;m_hWnd,findPanel,0);
  
      CWnd* pointTest = NULL;
  
      CString text = "";
  
      int xx = 337;
      int yy = 95;
  
      while(yy &lt; 1024 &amp;&amp; (pointTest == NULL || strcmp(text,"") == 0 || strcmp(text,"Panel2") == 0))
      {
          pointTest = mainWindow-&gt;ChildWindowFromPoint(CPoint(xx,yy));
          yy++;
          if(pointTest != 0)
              pointTest-&gt;GetWindowTextA(text);
      }
  
  
  
      if(strcmp(text,"") != 0)
          MessageBox(0,text,0); // This never shows
  
  }
  </code></pre>