For Win32 GUI debugging I'm usually using WinSpector (I highly recommend it), but as it turns out WinSpector doesn't display owner windows (or maybe I just can't find it).
I was debugging a foreground activation error when the application was running through Citrix. As it turns out in certain combinations of Citrix clients and Citrix server registry setting, the windows ownership on the client is different than on the desktop.
I highly doubt this will be useful to anyone else but me, but here it goes anyway: lshwnd - program for listing all HWNDs, their parents and their owners.
#define UNICODE
#include <windows.h>
#include <vector>
wchar_t name[1000];
BOOL CALLBACK myEnum(HWND hwnd, LPARAM lParam)
{
std::vector<HWND> *windows = (std::vector<HWND>*)lParam;
windows->push_back(hwnd);
}
void enumerate(HWND hwnd, int depth)
{
std::vector<HWND> windows;
EnumChildWindows(hwnd, myEnum, LPARAM(&windows));
GetWindowText(hwnd, name, 1000);
for (int i = 0; i < depth; i++)
wprintf(L" ");
wprintf(L"%x:%x - %s\n", hwnd, GetAncestor(hwnd, GA_ROOTOWNER), name);
for (int i = 0; i < windows.size(); i++)
{
enumerate(windows[i], depth+1);
}
}
int main()
{
enumerate(NULL, 0);
return 0;
}
Usage is quite easy, you start
lshwnd.exe > hwnd.txtand you will get a list of all your HWNDs in a tree structure according to parent child relationship. Every HWND is represented as
parent:parent_owner parent_window_title child:child_owner child_window_title
Version for download lshwnd.zip - 11 kB
0 comments:
Post a Comment