Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
While making a program I encountered a problem. I want that during the execution time of my program if a new window is opened on my laptop screen then my program should print 1 and do this for every new window opened until I close the program.
Thank you
Posted

You can install a hook procedure using the SetWindowsHookEx function[^].

The best procedure type for your request will be probably WH_CALLWNDPROCRET. From inside the procedure handler check for a message that is involved with window creation like WM_CREATE.
 
Share this answer
 
Another idea is to catch WM_NCPAINT Message, WM_NCPAINT message means your window frame has been invalidated because other window might have overlapped, this could be tricky because WM_NCPAINT message can also be triggered when no window overlapped. Check this for further details.


WM_NCPAINT message (Windows)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900