如何获取屏幕的坐标信息

#include 
#include 
#include 

BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);

int main()
{
	// 枚举每个显示器
	std::vector<MONITORINFOEX> monitors;
	EnumDisplayMonitors(nullptr, nullptr, MonitorEnumProc, reinterpret_cast<LPARAM>(&monitors));

	// 输出每个显示器的分辨率和起点信息
	for (int i = 0; i < monitors.size(); i++)
	{
		std::cout << "Screen " << i << " Resolution: " << monitors[i].rcMonitor.right - monitors[i].rcMonitor.left << "x" << monitors[i].rcMonitor.bottom - monitors[i].rcMonitor.top << std::endl;
		std::cout << "Screen " << i << " Origin: (" << monitors[i].rcMonitor.left << ", " << monitors[i].rcMonitor.top << ")" << std::endl;
	}

	system("pause");
	return 0;
}

BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
	std::vector<MONITORINFOEX>* pMonitors = reinterpret_cast<std::vector<MONITORINFOEX>*>(dwData);

	MONITORINFOEX monitorInfo;
	monitorInfo.cbSize = sizeof(MONITORINFOEX);
	GetMonitorInfo(hMonitor, &monitorInfo);

	pMonitors->push_back(monitorInfo);

	return TRUE;
}

如何获取屏幕的坐标信息_第1张图片

你可能感兴趣的:(C/C++基础,windows编程,c++,开发语言)