How can I be notified when a new window is created on Win32?

前端 未结 5 1583
不思量自难忘°
不思量自难忘° 2020-12-08 11:29

Is there a way using Win32, to register for notifications when a new window is created. I\'m trying to keep a list of current open windows, but am now just polling the list

5条回答
  •  青春惊慌失措
    2020-12-08 12:21

    Sure - you can write a CBT hook and watch for HCBT_CREATEWND. See also SetWindowsHookEx().


    Note that this will allow you to be notified of all window creation, before the windows being created are even fully initialized. If all you need are unowned, top-level windows, RichieHindle's suggestion may work better...

提交回复
热议问题