【发布时间】:2014-10-11 08:08:09
【问题描述】:
试图通过物理监视器运行 for 循环,但句柄真的让我感到困惑,我有伪代码运行如下:
int tempCounter=0
for(counter = number of monitors;counter > 0;counter--){
RECT tempRECT;
HDC tempHDC;
Get resolution of DC handle (counter) -> tempRECT;
arrayList[tempCounter] = tempRECT;
Get virtual work area of DC handle (counter) -> tempRECT;
arrayList[tempCounter++] = tempRECT;
tempCounter++;
}
GetSystemMetrics(80) 用于监视器的计数,这是否足够可靠以使用,或者它可能会失败的任何异常?
我知道那里没有什么,但是看 MSDN 让我一直在兜圈子,而且我不是很擅长编程。
【问题讨论】:
-
您的实际代码应该是错误的,伪代码没有显示问题。
EnumDisplayMonitors是您枚举监视器的方式(没有计数器)。 -
我确实意识到我需要使用 EnumDisplayMonitors,但这让我很困惑。 MSDN 真的让我很困惑如何做我想做的事。我也不确定如何获得不同显示器的句柄。
-
您调用
EnumDisplayMonitors并传递您的函数,该函数为您调用并接收监视器句柄作为参数。另外,this code snippet shows the usage. -
@BuiltonSin:你知道什么是回调函数吗?因为这是使用
EnumDisplayMonitors函数的关键。 -
我见过回调,但没有,我不知道它们是什么。也许这就是为什么我一直如此困惑!非常感谢。 立即开始研究
标签: c++ resolution gdi monitors