다음을 통해 공유


StringFormat::GetTabStops 메서드(gdiplusstringformat.h)

StringFormat::GetTabStops 메서드는 이 StringFormat 개체에서 탭 정지의 오프셋을 가져옵니다.

구문

Status GetTabStops(
  [in]  INT  count,
  [out] REAL *firstTabOffset,
  [out] REAL *tabStops
);

매개 변수

[in] count

형식: INT

tabStops 배열의 탭 중지 오프셋 수를 지정하는 정수입니다.

[out] firstTabOffset

형식: REAL*

초기 오프셋 위치를 수신하는 REAL 에 대한 포인터입니다. 이 초기 오프셋 위치는 문자열의 원본을 기준으로 하며 첫 번째 탭 중지의 오프셋은 초기 오프셋 위치를 기준으로 합니다.

[out] tabStops

형식: REAL*

탭 중지 오프셋을 수신하는 REAL 형식의 배열에 대한 포인터입니다. 첫 번째 탭 중지의 오프셋은 배열의 첫 번째 값, 두 번째 탭 중지의 오프셋, 배열의 두 번째 값 등입니다.

반환 값

형식: 상태

메서드가 성공하면 Status 열거형의 요소인 Ok를 반환합니다.

메서드가 실패하면 Status 열거형의 다른 요소 중 하나를 반환합니다.

설명

tabStops 배열의 각 탭 중지 오프셋(첫 번째 오프셋 제외)은 이전 오프셋과 상대적입니다. 첫 번째 탭 중지 오프셋은 firstTabOffset으로 표시된 초기 오프셋 위치를 기준으로 합니다. 예를 들어 초기 오프셋 위치가 8이고 첫 번째 탭 중지 오프셋이 50인 경우 첫 번째 탭 중지 위치는 58입니다. 초기 오프셋 위치가 0이면 첫 번째 탭 중지 오프셋은 문자열 원점인 위치 0을 기준으로 합니다.

예제

다음 예제에서는 StringFormat 개체를 만들고 탭 중지를 설정하며 StringFormat 개체를 사용하여 탭 문자(\t)가 포함된 문자열을 그립니다. 또한 이 코드는 문자열의 레이아웃 사각형을 그립니다. 그런 다음, 코드는 탭 정지를 가져오고 어떤 식으로든 탭 정지를 사용하거나 검사합니다.

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

   REAL         tabs[] = {150, 100, 100};
   FontFamily   fontFamily(L"Courier New");
   Font         font(&fontFamily, 12, FontStyleRegular, UnitPoint);
   SolidBrush   solidBrush(Color(255, 0, 0, 255));

   StringFormat stringFormat;
   stringFormat.SetTabStops(0, 3, tabs);
   graphics.DrawString(
      L"Name\tTest 1\tTest 2\tTest 3", 
      25, 
      &font, 
      RectF(20, 20, 500, 100), 
      &stringFormat, 
      &solidBrush);

   // Draw the rectangle that encloses the text.
   Pen pen(Color(255, 255, 0, 0));
   graphics.DrawRectangle(&pen, 20, 20, 500, 100);

   // Get the tab stops.
   INT   tabStopCount = 0;
   REAL  firstTabOffset = 0;
   REAL* tabStops = NULL;

   tabStopCount = stringFormat.GetTabStopCount();
   tabStops = (REAL*)malloc(tabStopCount*sizeof(REAL));
   stringFormat.GetTabStops(tabStopCount, &firstTabOffset, tabStops);

   for(INT j = 0; j < tabStopCount; ++j)
   {
      // Inspect or use the value in tabStops[j].
   }
}

요구 사항

   
지원되는 최소 클라이언트 Windows XP, Windows 2000 Professional [데스크톱 앱만 해당]
지원되는 최소 서버 Windows 2000 Server[데스크톱 앱만]
대상 플랫폼 Windows
헤더 gdiplusstringformat.h(Gdiplus.h 포함)
라이브러리 Gdiplus.lib
DLL Gdiplus.dll

참고 항목

텍스트 서식 지정

상태

StringFormat