【发布时间】:2011-05-09 01:17:43
【问题描述】:
我开发了一个简单的 Windows 窗体应用程序来捕获视频聊天应用程序的窗口(入站,也称为远程和出站,也就是本地)。 我为此使用非托管 Windows API 代码。这是捕获代码:
// Set Local Window
localHandle = FindWindow(null, "local");
// Backup parent window for local
prevLocalHandle = GetParent(localHandle);
SetParent(localHandle, this.pBoxLocal.Handle);
SetWindowLong(localHandle, GWL_STYLE, WS_VISIBLE + (WS_MAXIMIZE | WS_BORDER | WS_DISABLED));
MoveWindow(localHandle, 0, -TOP_BAR_HEIGHT, this.pBoxLocal.Width, this.pBoxLocal.Height + LOWER_BAR_HEIGHT, true);
// Set Remote Window
remoteHandle = FindWindow(null, "remote");
// Backup parent window for remote
prevRemoteHandle = GetParent(remoteHandle);
SetParent(remoteHandle, this.pBoxRemote.Handle);
SetWindowLong(remoteHandle, GWL_STYLE, WS_VISIBLE + (WS_MAXIMIZE | WS_BORDER | WS_DISABLED));
MoveWindow(remoteHandle, 0, -TOP_BAR_HEIGHT, this.pBoxRemote.Width, this.pBoxRemote.Height + LOWER_BAR_HEIGHT, true);
这是返回码:
// Return Windows
SetParent(localHandle, prevLocalHandle);
SetWindowLong(localHandle, GWL_STYLE, (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX));
MoveWindow(localHandle, 0, 0, NORMAL_WIDTH, NORMAL_HEIGHT, true);
SetParent(remoteHandle, prevRemoteHandle);
SetWindowLong(remoteHandle, GWL_STYLE, (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX));
MoveWindow(remoteHandle, 0, 0, NORMAL_WIDTH, NORMAL_HEIGHT, true);
我们的目标是:
到这里:
然后又回来了! :)
目前我的做事方式有两个问题:
首先,当我将窗口返回到视频聊天应用程序时,偶尔会在我的屏幕左上角留下一个黑色矩形。当我刷新该区域时它会消失。
其次,也是最重要的,有时当我捕获应用程序的窗口时,我也会捕获它的工具栏(尽管我提供的测量值只是关于窗口视频区域的测量值)。
有没有更好的方法来做到这一点?即使它只是更好的功能!记住:我想获取视频聊天应用的窗口,然后返回。
提前感谢您的任何提示!
【问题讨论】: