그래픽::BeginContainer

Graphics::BeginContainer 메서드는 새 그래픽 컨테이너를 시작합니다.

구문

GraphicsContainer BeginContainer();

반환 값

형식: GraphicsContainer

이 메서드는 컨테이너를 식별하는 값을 반환합니다.

설명

이 메서드를 사용하여 중첩된 그래픽 컨테이너를 만듭니다. 그래픽 컨테이너는 변환, 클리핑 영역 및 다양한 렌더링 속성과 같은 그래픽 상태를 유지하는 데 사용됩니다.

Graphics::BeginContainer 메서드는 GraphicsContainer 형식의 값을 반환합니다. 컨테이너 사용을 마쳤으면 해당 값을 Graphics::EndContainer 메서드에 전달합니다. GraphicsContainer 데이터 형식은 Gdiplusenums.h에 정의되어 있습니다.

Graphics 개체의 Graphics::BeginContainer 메서드를 호출하면 Graphics 개체의 상태를 보유하는 정보 블록이 스택에 배치됩니다. Graphics::BeginContainer 메서드는 해당 정보 블록을 식별하는 값을 반환합니다. 식별 값을 Graphics::EndContainer 메서드에 전달하면 정보 블록이 스택에서 제거되고 Graphics::BeginContainer 호출 당시의 상태로 Graphics 개체를 복원하는 데 사용됩니다.

컨테이너를 중첩할 수 있습니다. 즉, Graphics::EndContainer 메서드를 호출하기 전에 Graphics::BeginContainer 메서드를 여러 번 호출할 수 있습니다. Graphics::BeginContainer 메서드를 호출할 때마다 정보 블록이 스택에 배치되고 정보 블록에 대한 식별자가 표시됩니다. 해당 식별자 중 하나를 Graphics::EndContainer 메서드에 전달하면 Graphics 개체는 해당 특정 식별자를 반환한 Graphics::BeginContainer 호출 당시의 상태로 반환됩니다. Graphics::BeginContainer 호출에 의해 스택에 배치된 정보 블록이 스택에서 제거되고 해당 Graphics::BeginContainer 호출 이후에 해당 스택에 배치된 모든 정보 블록도 제거됩니다.

Graphics::Save 메서드를 호출하면 Graphics::BeginContainer 메서드에 대한 호출과 동일한 스택에 정보 블록이 배치됩니다. Graphics::EndContainer 호출이 Graphics::BeginContainer 호출과 쌍을 이루는 것처럼 Graphics::Restore 호출은 Graphics::Save 호출과 쌍을 이릅니다.

주의Graphics::EndContainer를 호출하면 그래픽::BeginContainer에 대한 해당 호출 후 스택에 배치된 모든 정보 블록(Graphics::Save 또는 Graphics::BeginContainer)이 스택에서 제거됩니다. 마찬가지로 Graphics::Restore를 호출하면 Graphics::Save에 대한 해당 호출 후 스택에 배치된 모든 정보 블록(Graphics::Save 또는 Graphics::BeginContainer)이 스택에서 제거됩니다.
 
그래픽 컨테이너에 대한 자세한 내용은 중첩 그래픽 컨테이너를 참조하세요.

예제

다음 예제에서는 Graphics 개체의 클리핑 영역을 설정하고 그래픽 컨테이너를 시작합니다. 그런 다음 컨테이너에 대한 추가 클리핑 영역을 설정하고 컨테이너 내부의 효과적인 클리핑 영역을 보여 주는 사각형을 그립니다.

VOID Example_BeginContainer(HDC hdc)
{
   Graphics graphics(hdc);

   // Set the clipping region for the Graphics object.
   graphics.SetClip(Rect(10, 10, 150, 150));

   // Begin a graphics container.
   GraphicsContainer container = graphics.BeginContainer();

   // Set an additional clipping region for the container.
   graphics.SetClip(Rect(100, 50, 100, 75));

   // Fill a red rectangle in the container.
   SolidBrush redBrush(Color(255, 255, 0, 0));
   graphics.FillRectangle(&redBrush, 0, 0, 400, 400);

   // End the container, and fill the same rectangle with blue. 
   graphics.EndContainer(container);
   SolidBrush blueBrush(Color(128, 0, 0, 255));
   graphics.FillRectangle(&blueBrush, 0, 0, 400, 400);

   // Set the clipping region to infinite, and draw the outlines 
   // of the two previous clipping regions.
   graphics.ResetClip();
   Pen blackPen(Color(255, 0, 0, 0), 2.0f);
   graphics.DrawRectangle(&blackPen, 10, 10, 150, 150);
   graphics.DrawRectangle(&blackPen, 100, 50, 100, 75);
}

요구 사항

   
지원되는 최소 클라이언트 Windows 10 빌드 20348
지원되는 최소 서버 Windows 10 빌드 20348
머리글 gdiplusgraphics.h

참고 항목

그래픽

그래픽 컨테이너

그래픽::EndContainer

그래픽::복원

그래픽::저장

그래픽 컨테이너 사용