等待禁用航空完成
我的应用程序有一个选项可以通过在捕获屏幕图像之前调用 DwmEnableComposition(0) 来禁用 aero。如您所知,禁用 Aero 会使屏幕变黑,然后恢复正常。在不同的 PC 上,这可能需要 2 到 3 秒,具体取决于系统的速度。
有没有更好的方法来确定 aero 在屏幕捕获之前是否已完全禁用而不是 Thread.Sleep()?
My app has an option to disable aero by calling DwmEnableComposition(0) before capturing a screen image. As you know, disabling aero makes the screen go black then return to normal afterwards. On different PCs this might take 2 to 3 seconds depending on how fast the system is.
Is there a better way of determining if aero has fully disabled before screen capture instead of Thread.Sleep()?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该能够使用相关的 API 函数 来执行此操作DwmIsCompositionEnabled。另一个选项可能是监听
WM_DWMCOMPOSITIONCHANGED
事件。You should be able to do this using the related API function DwmIsCompositionEnabled. The other option might be to listen for the
WM_DWMCOMPOSITIONCHANGED
event.您的表单的 Paint 事件将运行。这并不意味着所有窗户都将被完全粉刷,但您可以睡得更少。通过重写 WndProc() 监听通知消息可能有效,但不确定它何时发送。 WM_DWMCOMPOSITIONCHANGED 是消息 0x31e。我怀疑它发送得太快了,接下来所有的窗口可能都必须重新粉刷。唯一确定的方法是使用 EnumWindows 枚举窗口并调用 UpdateWindow。请访问 pinvoke.net 以获取您需要的 P/Invoke 声明。 Sleep() 也可以工作,但无法猜测保证在任何地方都能工作的数量。
Your form's Paint event will run. That doesn't mean all windows will be fully painted, but you can sleep less. Listening for the notification message by overriding WndProc() may work, not sure when it is sent. WM_DWMCOMPOSITIONCHANGED is message 0x31e. I suspect it will be sent too soon, all windows probably have to repaint themselves next. The only way to be sure is to enumerate the windows with EnumWindows and call UpdateWindow. Visit pinvoke.net for the P/Invoke declarations you'll need. Sleep() will work too but there's no way to guess an amount that's guaranteed to work everywhere.
您是否研究过DwmIsCompositionEnabled?此页面还表示应用程序可以通过处理 WM_DWMCOMPOSITIONCHANGED 通知。
Have you looked into DwmIsCompositionEnabled? This page also says Applications can listen for composition state changes by handling the WM_DWMCOMPOSITIONCHANGED notification.