// Листинг 1.11. Использование регионов для графических построений RECT pRect = {-100, -100, 100, 100}; RECT pEllips = {-120, -80, 120, 80}; RECT pSm = {-60, -40, 60, 40}; const int WIDTH = 400; LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; static int sx, sy; HRGN hRgnEllipse; HRGN hRgn; static HBRUSH hBrush; switch (message) { case WM_SIZE: sx = LOWORD(lParam); sy = HIWORD(lParam); break; case WM_CREATE: hBrush = CreateSolidBrush(RGB(0, 0, 255)); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); SetMapMode(hdc, MM_ANISOTROPIC); SetWindowExtEx(hdc, WIDTH, - WIDTH, NULL); SetViewportExtEx(hdc, sx, sy, NULL); SetViewportOrgEx(hdc, sx/2, sy/2, NULL); hRgn = CreateRectRgnIndirect(&pRect); hRgnEllipse = CreateEllipticRgnIndirect(&pEllips); CombineRgn(hRgn, hRgn, hRgnEllipse, RGN_DIFF); DeleteObject(hRgnEllipse); hRgnEllipse = CreateEllipticRgnIndirect(&pSm); CombineRgn(hRgn, hRgn, hRgnEllipse, RGN_OR); DeleteObject(hRgnEllipse); FillRgn(hdc, hRgn, hBrush); DeleteObject(hRgn); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }