Improve: Support multiple screen desktop monitoring
This commit is contained in:
@@ -84,6 +84,25 @@ private:
|
||||
|
||||
class ScreenCapture
|
||||
{
|
||||
private:
|
||||
static BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
||||
{
|
||||
std::vector<MONITORINFOEX>* monitors = reinterpret_cast<std::vector<MONITORINFOEX>*>(dwData);
|
||||
|
||||
MONITORINFOEX mi;
|
||||
mi.cbSize = sizeof(MONITORINFOEX);
|
||||
if (GetMonitorInfo(hMonitor, &mi))
|
||||
{
|
||||
monitors->push_back(mi); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϣ
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
std::vector<MONITORINFOEX> GetAllMonitors()
|
||||
{
|
||||
std::vector<MONITORINFOEX> monitors;
|
||||
EnumDisplayMonitors(nullptr, nullptr, MonitorEnumProc, (LPARAM)&monitors);
|
||||
return monitors;
|
||||
}
|
||||
public:
|
||||
ThreadPool* m_ThreadPool; // <20>̳߳<DFB3>
|
||||
BYTE* m_FirstBuffer; // <20><>һ֡<D2BB><D6A1><EFBFBD><EFBFBD>
|
||||
@@ -119,13 +138,24 @@ public:
|
||||
|
||||
m_BlockNum = 8;
|
||||
m_ThreadPool = new ThreadPool(m_BlockNum);
|
||||
|
||||
if (all)
|
||||
static auto monitors = GetAllMonitors();
|
||||
static int index = 0;
|
||||
if (all && !monitors.empty())
|
||||
{
|
||||
m_iScreenX = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||
m_iScreenY = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||
m_ulFullWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
m_ulFullHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
int idx = index++ % (monitors.size()+1);
|
||||
if (idx == 0) {
|
||||
m_iScreenX = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||
m_iScreenY = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||
m_ulFullWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
m_ulFullHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
}
|
||||
else {
|
||||
RECT rt = monitors[idx-1].rcMonitor;
|
||||
m_iScreenX = rt.left;
|
||||
m_iScreenY = rt.top;
|
||||
m_ulFullWidth = rt.right - rt.left;
|
||||
m_ulFullHeight = rt.bottom - rt.top;
|
||||
}
|
||||
} else {
|
||||
//::GetSystemMetrics(SM_CXSCREEN/SM_CYSCREEN)<29><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB>С<EFBFBD><D0A1>
|
||||
//<2F><><EFBFBD>統<EFBFBD><E7B5B1>Ļ<EFBFBD><C4BB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϊ125%ʱ<><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>С<EFBFBD><D0A1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>1.25<EFBFBD>Ŷ<EFBFBD>
|
||||
@@ -411,6 +441,8 @@ public:
|
||||
pt.x *= m_wZoom;
|
||||
pt.y *= m_hZoom;
|
||||
}
|
||||
pt.x += m_iScreenX;
|
||||
pt.y += m_iScreenY;
|
||||
}
|
||||
|
||||
// <20><>ȡλͼ<CEBB>ṹ<EFBFBD><E1B9B9>Ϣ
|
||||
|
||||
Reference in New Issue
Block a user