-1

物理モニターを介して 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 を見ていると、ぐるぐる回っているだけで、プログラミングの能力があまりありません。

4

1 に答える 1

2

次のように簡単にできます。

#include <Windows.h>
#include <stdio.h>

BOOL CALLBACK MonitorEnumProc(
    HMONITOR hMonitor,
    HDC hdcMonitor,
    LPRECT lprcMonitor,
    LPARAM dwData
    )
{
    printf("%dx%d\n", lprcMonitor->right, lprcMonitor->bottom);
}

int main(int argc, char*argv[]) {

    EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, 0);
}
于 2014-10-11T09:37:01.703 に答える