cwinapidialoghwnd

In Win32, How can I detect if a HWND is a dialog?


In a pure C Win32 application, how can I detect if a HWND is a dialog?


Solution

  • Use GetClassLong() to find its class atom. Unless it was created with a custom window class (very unlikely), its class will be WC_DIALOG.

    if ( WC_DIALOG == MAKEINTATOM(GetClassLong(hWnd, GCW_ATOM)) )
    {
        /* this is a dialog */
    }