0

I have worked on XAML-based UWP apps and the Live Visual Tree feature proved handy sometimes to inspect the actual dimensions and properties of UI elements within the app. Is there something similar to inspect native elements within a Win32 desktop app where I can query the dimensions of native views within the app?

Zoso
  • 3,273
  • 1
  • 16
  • 27
  • Windows SDK used to include a tool named Spy++, and there are plenty of clones around. – Ben Voigt Apr 27 '22 at 16:12
  • See [this answer](https://stackoverflow.com/a/4537611/103167) for a screenshot, showing that it displays the dimensions of child windows. – Ben Voigt Apr 27 '22 at 16:14
  • 2
    I would suggest a UIA inspection tool instead of spy++. UIA can tell you the size and location of things that aren't HWND-based. – SoronelHaetir Apr 27 '22 at 16:52
  • @SoronelHaetir Using [Accesiibilty Insights](https://accessibilityinsights.io/downloads/) did the trick for me. – Zoso Apr 27 '22 at 19:54
  • "Acc" makes me think it's based on the older active accessibility API. While that should be sufficient for size and location, UIA can tell you a whole lot more. – SoronelHaetir Apr 27 '22 at 20:38
  • @SoronelHaetir Would you suggest using the `VisualUIAVerifyNative` that's bundled with the SDK? That doesn't seem to highlight the exact element that I'm interested in though it does highlight other elements. I'm not sure why that's the case. – Zoso Apr 27 '22 at 20:58
  • Ok, I used the [Inspect](https://learn.microsoft.com/en-us/windows/win32/winauto/inspect-objects) UIA tool which seems to offer much more information (regarding `hWnd` wherever applicable) – Zoso Apr 27 '22 at 21:10
  • I do like Visual UIA Verify (and note I depend heavily upon accessibility as I am blind). I am surprised there would be anything that shows up in an active accessibility tool that doesn't in UIA (though not by the reverse). – SoronelHaetir Apr 27 '22 at 21:11

1 Answers1

0

Since you're specifically asking for native windows, recursively calling EnumChildWindows is the appropriate solution. Once you have an HWND you can call GetWindowRect to retrieve the window dimensions.

IInspectable
  • 46,945
  • 8
  • 85
  • 181