[英]How to get main window handle from a child window handle
我想從前台窗口獲取主窗口的句柄。
hWnd = GetForegroundWindow();
hwndOwner = GetWindow(hWnd, GW_OWNER);
hwndParent = GetParent(hWnd);
hwndOwner
和hwndParent
只是前景窗口上方的一層。 如何在不遞歸調用上述函數的情況下獲取主窗口句柄?
使用帶有 GA_ROOT 標志的 GetAncestor: GetAncestor(hwndChild, GA_ROOT);
請注意,我不確定 GA_ROOT 和 GA_ROOTOWNER 之間的區別。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.