I want to handle a situation when Windows wakes up displays from the sleep mode, but when OS not in sleep mode itself. This situation happens when the user was inactive for some time and the OS put the display into sleep mode for power saving. And after some time user wakes up, and the OS switch on the display.

This behavior adjusted in power options, like on the screenshot below: enter image description here

I was hoping to get a notification from the OS in WindowProc functions, but this approach doesn't work. Maybe need to register such kind of notifications by some function like WTSRegisterSessionNotification.

2 Answers

Rudolfs Bundulis On Best Solutions

Try RegisterPowerSettingNotification together with the power guid GUID_SESSION_DISPLAY_STATUS.

Strive Sun On

You can try the WM_POWERBROADCAST message

Like this case:

Get Notified about Windows is Going to Sleep/Waking up in C++