我想从前景窗口获取主窗口的句柄。
hWnd = GetForegroundWindow();
hwndOwner = GetWindow(hWnd, GW_OWNER);
hwndParent = GetParent(hWnd);
hwndOwner
和hwndParent
只是前景窗口上方的一层。如何在不递归调用上述函数的情况下获取主窗口句柄?
答案 0 :(得分:0)
将GetAncestor与GA_ROOT标志一起使用: GetAncestor(hwndChild,GA_ROOT);
请注意,我不确定GA_ROOT和GA_ROOTOWNER之间的区别。