在跨越多個顯示器的 DC 上繪製

若要回應 WM_PAINT 訊息,請使用如下所示的程式碼。

case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
EnumDisplayMonitors(hdc, NULL, MyPaintEnumProc, 0);
EndPaint(hwnd, &ps);
 

若要繪製視窗的上半部,請使用如下所示的程式碼。

GetClient Rect(hwnd, &rc);
rc.bottom = (rc.bottom - rc.top) / 2;
hdc = GetDC(hwnd);
EnumDisplayMonitors(hdc, &rc, MyPaintEnumProc, 0);
ReleaseDC(hwnd, hdc);

若要針對每個監視器以最佳方式繪製整個虛擬螢幕,請使用如下所示的程式碼。

hdc = GetDC(NULL);
EnumDisplayMonitors(hdc, NULL, MyPaintScreenEnumProc, 0);
ReleaseDC(NULL, hdc);