0

WinAPI を使用して C++ で記述されたスクリーンセーバーを複数のモニターで動作するように適応させようとしています。この基本的な WM_PAINT ハンドラを書き直すことを提案するこの記事を見つけました。

case WM_PAINT:
{
    PAINTSTRUCT ps = {0};
    HDC hdc = BeginPaint(hWnd, &ps );

    DoDrawing(hdc, ps.rcPaint);

    EndPaint(hWnd, &ps);
}
break;

void DoDrawing(HDC hDC, RECT rcDraw)
{
    //Do actual drawing in 'hDC'
}

複数の画面の描画を組み込むには、次のようにします。

case WM_PAINT:
{
    PAINTSTRUCT ps = {0};
    HDC hdcE = BeginPaint(hWnd, &ps );

    EnumDisplayMonitors(hdcE,NULL, MyPaintEnumProc, 0);

    EndPaint(hWnd, &ps);
}
break;

BOOL CALLBACK MyPaintEnumProc(
      HMONITOR hMonitor,  // handle to display monitor
      HDC hdc1,     // handle to monitor DC
      LPRECT lprcMonitor, // monitor intersection rectangle
      LPARAM data       // data
      )
{
    RECT rc = *lprcMonitor;
    // you have the rect which has coordinates of the monitor

    DoDrawing(hdc1, rc);

    // Draw here now
    return 1;
}

しかし、私が持っている質問は、BeginPaint() が WM_PAINT メッセージを処理した後に DC で設定する特別な最適化/クリッピングについてです。このアプローチでは、それは失われます。EnumDisplayMonitors() 呼び出し全体でそれを保持する方法はありますか?

4

1 に答える 1