summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/diaglib/nativewindowdump_win.cpp48
1 files changed, 40 insertions, 8 deletions
diff --git a/tests/manual/diaglib/nativewindowdump_win.cpp b/tests/manual/diaglib/nativewindowdump_win.cpp
index e3885eb96d..b25f8aa864 100644
--- a/tests/manual/diaglib/nativewindowdump_win.cpp
+++ b/tests/manual/diaglib/nativewindowdump_win.cpp
@@ -48,9 +48,10 @@
namespace QtDiag {
struct DumpContext {
- DumpContext() : indentation(0) {}
+ DumpContext() : indentation(0), parent(0) {}
int indentation;
+ HWND parent;
QSharedPointer<QTextStream> stream;
};
@@ -64,11 +65,19 @@ static void formatNativeWindow(HWND hwnd, QTextStream &str)
RECT rect;
if (GetWindowRect(hwnd, &rect)) {
str << ' ' << (rect.right - rect.left) << 'x' << (rect.bottom - rect.top)
- << '+' << rect.left << '+' << rect.top;
+ << forcesign << rect.left << rect.top << noforcesign;
}
if (IsWindowVisible(hwnd))
str << " [visible]";
+ wchar_t buf[512];
+ if (GetWindowText(hwnd, buf, sizeof(buf)/sizeof(buf[0])) && buf[0])
+ str << " title=\"" << QString::fromWCharArray(buf) << "\"/";
+ else
+ str << ' ';
+ if (GetClassName(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
+ str << '"' << QString::fromWCharArray(buf) << '"';
+
str << hex << showbase;
if (const LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE)) {
str << " style=" << style;
@@ -121,13 +130,31 @@ static void formatNativeWindow(HWND hwnd, QTextStream &str)
debugWinStyle(str, exStyle, WS_EX_COMPOSITED)
debugWinStyle(str, exStyle, WS_EX_NOACTIVATE)
}
+
+ if (const ULONG_PTR classStyle = GetClassLongPtr(hwnd, GCL_STYLE)) {
+ str << " classStyle=" << classStyle;
+ debugWinStyle(str, classStyle, CS_BYTEALIGNCLIENT)
+ debugWinStyle(str, classStyle, CS_BYTEALIGNWINDOW)
+ debugWinStyle(str, classStyle, CS_CLASSDC)
+ debugWinStyle(str, classStyle, CS_DBLCLKS)
+ debugWinStyle(str, classStyle, CS_DROPSHADOW)
+ debugWinStyle(str, classStyle, CS_GLOBALCLASS)
+ debugWinStyle(str, classStyle, CS_HREDRAW)
+ debugWinStyle(str, classStyle, CS_NOCLOSE)
+ debugWinStyle(str, classStyle, CS_OWNDC)
+ debugWinStyle(str, classStyle, CS_PARENTDC)
+ debugWinStyle(str, classStyle, CS_SAVEBITS)
+ debugWinStyle(str, classStyle, CS_VREDRAW)
+ }
+
+ if (const ULONG_PTR wndProc = GetClassLongPtr(hwnd, GCLP_WNDPROC))
+ str << " wndProc=" << wndProc;
+
str << noshowbase << dec;
- wchar_t buf[512];
- if (GetWindowText(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
- str << " title=\"" << QString::fromWCharArray(buf) << '"';
- if (GetClassName(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
- str << " class=\"" << QString::fromWCharArray(buf) << '"';
+ if (GetWindowModuleFileName(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
+ str << " module=\"" << QString::fromWCharArray(buf) << '"';
+
str << '\n';
}
@@ -135,7 +162,11 @@ static void dumpNativeWindowRecursion(HWND hwnd, DumpContext *dc);
BOOL CALLBACK dumpWindowEnumChildProc(HWND hwnd, LPARAM lParam)
{
- dumpNativeWindowRecursion(hwnd, reinterpret_cast<DumpContext *>(lParam));
+ DumpContext *dumpContext = reinterpret_cast<DumpContext *>(lParam);
+ // EnumChildWindows enumerates grand children as well, skip these to
+ // get the hierarchical formatting right.
+ if (GetAncestor(hwnd, GA_PARENT) == dumpContext->parent)
+ dumpNativeWindowRecursion(hwnd, dumpContext);
return TRUE;
}
@@ -145,6 +176,7 @@ static void dumpNativeWindowRecursion(HWND hwnd, DumpContext *dc)
formatNativeWindow(hwnd, *dc->stream);
DumpContext nextLevel = *dc;
nextLevel.indentation += 2;
+ nextLevel.parent = hwnd;
EnumChildWindows(hwnd, dumpWindowEnumChildProc, reinterpret_cast<LPARAM>(&nextLevel));
}