Debugging WIN32 focus bugs

前端 未结 3 713
死守一世寂寞
死守一世寂寞 2021-01-21 19:25

I\'m developing a WIN32/C++ application containing a main window and a lot of child windows, and I\'m looking for tools that could assist me in tracking down focus bugs.

3条回答
  •  一个人的身影
    2021-01-21 19:42

    The Inspect tool, part of the Windows SDK download, can be useful here. It's designed to test out the two Accessibility-related APIs - MSAA and UI Automation - and one of the things that both those APIs to is allow accessibility and test tools to track the focus.

    The simplest way to use it for tracking focus is to put it into MSAA mode, check the options to follow only focus changes (ie. turn off following the mouse pointer), then turn on the yellow highlight rectangle. Now as focus changes, you can see the rectangle move. As a bonus, if focus goes to something that's hidden or offscreen, you won't see a rectangle, but the name and Win32 class of the control will be displayed in the window.

    Note that Inspect shows a superset of focus events: you get not just HWND focus changes, but also notifications when focus moves within certain controls - such as between items in a list box. Automated test and accessibility need these, but for your purposes you should be ok to just ignore these; it's extra information, but shouldn't get in the way too much.

提交回复
热议问题