Wait for aero to turn off.

My application has the ability to disable aero by calling DwmEnableComposition (0) before capturing an image from the screen. As you know, turning off the aero makes the screen black and then returns to normal. On different PCs, this can take 2 to 3 seconds, depending on how fast the system is.

Is there a better way to determine if aero is completely disabled before capturing the screen rather than Thread.Sleep ()?

+3
source share
3 answers

Your Paint event will fire. This does not mean that all windows will be completely painted, but you can sleep less. Listening to the notification message by overriding WndProc () may work, but not necessarily, when it is sent. WM_DWMCOMPOSITIONCHANGED is a 0x31e message. I suspect that it will be sent too soon, all windows may have to be repainted further. The only way to make sure is to list the windows with EnumWindows and call UpdateWindow. Visit pinvoke.net for the P / Invoke ads you need. Sleep () will also work, but there is no way to guess the amount guaranteeing that it will work everywhere.

+1
source

, API DwmIsCompositionEnabled. WM_DWMCOMPOSITIONCHANGED.

+2

Have you looked at DwmIsCompositionEnabled ? This page also says that applications can listen to changes in the state of the composition by processing the WM_DWMCOMPOSITIONCHANGED notification .

+1
source

Source: https://habr.com/ru/post/1755973/


All Articles