C ++ - 如何屏幕捕获,除了一些窗口 [英] C++ - How to screen-capture, except for some windows

查看:366
本文介绍了C ++ - 如何屏幕捕获,除了一些窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:我有一个通过互联网执行屏幕共享的软件,其中一个用户充当演示者,其他用户充当观看者/与会者。

Situation: I have a software that performs screen sharing over the Internet, where one user acts as a presenter, and other users act as viewers/attendees.

除了演示窗口,演示者还有一组出现在屏幕上的非共享窗口(用于开始共享/停止共享等的按钮栏,Skype窗口等)。

Besides the presentation windows, the presenter also has a set of NON-SHARING-WINDOWS that appear on the screen (a button bar for start sharing/stop sharing/etc., a Skype window etc.).

演示者可以从屏幕共享软件的设置进行配置,使这些NON-SHARING-WINDOWS不可见(即它们不会出现在正在发送的屏幕共享中

The presenter can configure from the setup of the screen sharing software to make these NON-SHARING-WINDOWS invisible (i.e. they will not appear in the screen sharing that is being sent to the attendees, but the window content behind them will appear in the screenshot).

屏幕截图以大约每秒10帧或更快的速度发送。

The screenshots are sent at approximately 10 frames-per-second, or faster.

问题:如何以编程方式捕获屏幕,除了这些NON-SHARING-WINDOWS窗口?

Question: how can I programmatically capture the screen, except for these NON-SHARING-WINDOWS windows?

注释


  • 由于每秒钟的帧数较高,最大化/设置这些窗口的alpha,因为那么窗口会闪烁。应用程序是用Win32 C ++编写的。

  • 我将使用分层窗口,但由于Windows 7桌面组合功能,这不是可用的开箱即用8,您不能再临时使用DwmEnableComposition并以编程方式禁用组合)

  • 我可以使用Windows XP / 2000/7等分层窗口方法,如果有一个),虽然我喜欢一个工作在所有系统上的单个进程

  • 我也可以尝试通过捕获个人图像(桌面,窗口需要捕获),并使用它们的z-index创建最终图像,但由于所需的每秒帧数值,此过程将会太慢。

  • Because of the higher frames-per-second value, I cannot minimize/maximize/set alpha for these windows, because then the windows will flicker. The application is written in Win32 C++.
  • I would use layered windows, but because of the Windows 7 Desktop Composition feature, this is not usable out-of-the-box (and in Windows 8, you cannot use DwmEnableComposition anymore to temporarily and programmatically disable composition)
  • I could use the layered window approach for Windows XP/2000/7 etc., and a different approach for Windows 8 (if there is one), though I would prefer a single process that works on all systems
  • I could also try to "compose" the screenshots by capturing individual images (of the desktop, the windows that need to be captured) and using their z-index to create the final image, but because of the required frames-per-second value, this process would be too slow.

推荐答案

在窗口中,即使桌面被认为是一个窗口,并有自己的HWND。
然而,似乎不可能只复制壁纸自己。

In windows even the desktop is considered a window and has its own HWND. It seems however, not easily possible to only copy the "wallpaper" on its own.

所以我基本上看到两种方法来做到这一点。
1.复制整个桌面例如BitBlt(GetWindowDC(GetDesktopWindow()),...)

So i basically see two ways to do that. 1. Copy the entire desktop e.g. BitBlt(GetWindowDC(GetDesktopWindow()),...)


  1. 使用 GetWindow ,从桌面窗口开始,以反向方向遍历窗口列表,HWND可以通过GetDesktopWindow这个:

  1. Use GetWindow and traverse the window list in backward direction starting from the Desktop-Window whose HWND you just can determine with GetDesktopWindow(), Like this:

//画在黑色的DC上
hwnd = GetDesktopWindow()
while(hwnd = GetWindow ,GW_HWNDPREV))
{
//这个窗口不共享? continue
// else bitblt into into dc
}

Hope我给了一些灵感:-)
如果有人知道如何复制只有桌面没有其子窗口的方式,请让我知道。

Hope i gave some inspiration :-) If someone knows a way how to copy ONLY the desktop without its child windows please let me know.

这篇关于C ++ - 如何屏幕捕获,除了一些窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆