0

I'm trying to enumerate all controls inside a window using user32.dll, but I don't know exactly what I need to do.

I'm using EnumWindows and EnumChildWindows, but it doesn't retrieve all controls inside a window.

I want to get the text of some labels in a Delphi application.

I tried using Spy++, but it doesn't list too.

  • Delphi uses custom controls to an extent that EnumChildWindows will not work. Unfortunately I don't know if there's a solution for you. – Cory Nelson Sep 29 '14 at 18:40

2 Answers2

0
    IList<IntPtr> childern = new List<IntPtr>();
    WNDENUMPROC enumChildProc = delegate(IntPtr hwnd, IntPtr param)
    {
        childern.Add(hwnd);
        return true;
    };
    EnumChildWindows(Hwnd, enumChildProc, IntPtr.Zero);
    return childern;

which Hwnd is the parent window handle

Mohammad Mirmostafa
  • 1,720
  • 2
  • 16
  • 32
0

Delphi labels are non-windowed. That means that you cannot ever hope to obtain window handles for them since they are not windows.

If the Delphi VCL properly supported automation then you'd be able to use UI Automation to inspect the text of these controls. But the VCL only supports automation by dint of the underlying Win32 controls doing so. Since labels aren't windowed controls, again you are out of luck.

The only thing that can realistically hope to read this text is Delphi code inside the process. It does not sound as though that will be viable for you.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490