EnumDisplayDevices EnumDisplayMonitors 详看MSDN In order to query all display devices in the system, call this function in a loop, starting with iDevNum set to 0, and incrementing iDevNum until the function fails. Code Examples To paint in response to a WM_PAINT message, using the capabilities of each monitor, you can use code like the following in a window procedure: case WM_PAINT: hdc = BeginPaint(hwnd, &ps); EnumDisplayMonitors(hdc, NULL, MyPaintEnumProc, 0); EndPaint(hwnd, &ps); To paint the upper half of a window using the capabilities of each monitor, you can use code like the following: GetClientRect(hwnd, &rc); rc.bottom = (rc.bottom - rc.top) / 2; hdc = GetDC(hwnd); EnumDisplayMonitors(hdc, &rc, MyPaintEnumProc, 0); ReleaseDC(hwnd, hdc);
To paint the entire screen optimally for each display monitor, you can use code like the following: hdc = GetDC(NULL); EnumDisplayMonitors(hdc, NULL, MyPaintScreenEnumProc, 0); ReleaseDC(NULL, hdc);
To get information about all the display monitors, you can use code like the following: EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc, 0);
详看MSDN
In order to query all display devices in the system, call this function in a loop, starting with iDevNum set to 0, and incrementing iDevNum until the function fails.
Code Examples
To paint in response to a WM_PAINT message, using the capabilities of each monitor, you can use code like the following in a window procedure:
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
EnumDisplayMonitors(hdc, NULL, MyPaintEnumProc, 0);
EndPaint(hwnd, &ps);
To paint the upper half of a window using the capabilities of each monitor, you can use code like the following:
GetClientRect(hwnd, &rc);
rc.bottom = (rc.bottom - rc.top) / 2;
hdc = GetDC(hwnd);
EnumDisplayMonitors(hdc, &rc, MyPaintEnumProc, 0);
ReleaseDC(hwnd, hdc);
To paint the entire screen optimally for each display monitor, you can use code like the following:
hdc = GetDC(NULL);
EnumDisplayMonitors(hdc, NULL, MyPaintScreenEnumProc, 0);
ReleaseDC(NULL, hdc);
To get information about all the display monitors, you can use code like the following:
EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc, 0);