Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way do determine if an HWND represents a top-level window?

Is it to check for the WS_CHILD bit:

    LONG style = GetWindowLong(hwnd, GWL_STYLE);
    int isTopLevel = !(style & WS_CHILD);

Or is there a better way?

Assume: Straight C calling only existing Windows API code.

like image 916
0xbe5077ed Avatar asked Jun 06 '13 23:06

0xbe5077ed


1 Answers

  • Way #1: Test hWnd==GetAncestor(hWnd,GA_ROOT)

  • Way #2: Use IsTopLevelWindow (user32 Win7, undocumented)

like image 111
kero Avatar answered Oct 16 '22 01:10

kero