In a pure C Win32 application, how can I detect if a HWND
is a dialog?
Asked
Active
Viewed 547 times
2 Answers
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
-
2That's just the class atom in string form though :) – Jonathan Potter Oct 20 '20 at 05:26