Search code examples
cwindowsmonitorhwnd

Monitor creation of a window (HWND)


I would like to Monitor the creation of windows (HWND) in C.

I'd like to know if there's some kind of event that the WINAPI provides to handle the creation of a window.


Solution

  • If you are concerned only with top-level windows, you can use SetWindowHookEx to register a ShellProc and watch for HSHELL_WINDOWCREATED. If you need notification of the creation of any window, you can use a CallWndProc and watch for WM_CREATE messages.