1

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

rodrigocfd
  • 6,450
  • 6
  • 34
  • 68

2 Answers2

2

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 */
}
Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79
2

Dialogs have a standard class name of "#32770". You can use GetClassName()/RealGetWindowClass() 1 to check if a window is using a dialog class.

1: see What makes RealGetWindowClass so much more real than GetClassName?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770