Feat: window capture via PrintWindow with server-side HWND routing by clientID

This commit is contained in:
yuanyuanxiang
2026-06-15 13:08:23 +02:00
parent 5757ec7965
commit d3b9e7faae
16 changed files with 210 additions and 10 deletions

View File

@@ -95,10 +95,24 @@ protected:
BOOL m_bVirtualPaint;// 是否虚拟绘制
EnumHwndsPrintData m_data;
HWND m_hTargetWnd = NULL; // 窗口捕获目标NULL=全屏)
int m_ShadowLeft = 0; // DWM 阴影左偏移frameRc.left - fullRc.left帧间缓存
int m_ShadowTop = 0; // DWM 阴影上偏移frameRc.top - fullRc.top帧间缓存
int m_CachedWndW = 0; // 上帧 GetWindowRect 宽度,用于检测 resize 无需每帧调 DWM
int m_CachedWndH = 0; // 上帧 GetWindowRect 高度
int m_PendingWndW = 0; // 防抖:检测到尺寸变化后记录的新宽度
int m_PendingWndH = 0; // 防抖:检测到尺寸变化后记录的新高度
DWORD m_SizeChangeTick = 0; // 防抖尺寸上次变化的时间戳GetTickCount
public:
CScreenSpy(ULONG ulbiBitCount, BYTE algo, BOOL vDesk = FALSE, int gop = DEFAULT_GOP, BOOL all = FALSE,
int level = LEVEL_H264_SOFT, RECT rc = {0}, BOOL switchScreen = TRUE);
CScreenSpy(ULONG ulbiBitCount, BYTE algo, BOOL vDesk = FALSE, int gop = DEFAULT_GOP, BOOL all = FALSE,
int level = LEVEL_H264_SOFT, RECT rc = {0}, BOOL switchScreen = TRUE, HWND hwnd = NULL);
virtual HWND GetTargetWindow() const override { return m_hTargetWnd; }
// 窗口模式下 m_ulFullWidth/Height 是窗口尺寸,但 SendInput 的 dx/dy 分母必须是屏幕尺寸
virtual int GetScreenWidth() const override { return m_hTargetWnd ? GetSystemMetrics(SM_CXSCREEN) : m_ulFullWidth; }
virtual int GetScreenHeight() const override { return m_hTargetWnd ? GetSystemMetrics(SM_CYSCREEN) : m_ulFullHeight; }
virtual ~CScreenSpy();