Share via


CDC::GetTabbedTextExtent

Call this member function to compute the width and height of a character string using m_hAttribDC, the attribute device context.

CSize GetTabbedTextExtent(
   LPCTSTR lpszString,
   int nCount,
   int nTabPositions,
   LPINT lpnTabStopPositions 
) const;
CSize GetTabbedTextExtent(
   const CString& str,
   int nTabPositions,
   LPINT lpnTabStopPositions 
) const;

Parameters

  • lpszString
    Points to a character string. You can also pass a CString object for this parameter.

  • nCount
    Specifies the number of characters in the string. If nCount is –1, the length is calculated.

  • nTabPositions
    Specifies the number of tab-stop positions in the array pointed to by lpnTabStopPositions.

  • lpnTabStopPositions
    Points to an array of integers containing the tab-stop positions in logical units. The tab stops must be sorted in increasing order; the smallest x-value should be the first item in the array. Back tabs are not allowed.

  • str
    A CString object that contains the specified characters to be drawn.

Return Value

The dimensions of the string (in logical units) in a CSize object.

Remarks

If the string contains one or more tab characters, the width of the string is based upon the tab stops specified by lpnTabStopPositions. The function uses the currently selected font to compute the dimensions of the string.

The current clipping region does not offset the width and height returned by the GetTabbedTextExtent function.

Since some devices do not place characters in regular cell arrays (that is, they kern the characters), the sum of the extents of the characters in a string may not be equal to the extent of the string.

If nTabPositions is 0 and lpnTabStopPositions is NULL, tabs are expanded to eight times the average character width. If nTabPositions is 1, the tab stops will be separated by the distance specified by the first value in the array to which lpnTabStopPositions points. If lpnTabStopPositions points to more than a single value, a tab stop is set for each value in the array, up to the number specified by nTabPositions.

Requirements

Header: afxwin.h

See Also

Reference

CDC Class

Hierarchy Chart

CDC::GetTextExtent

CDC::GetOutputTabbedTextExtent

CDC::GetOutputTextExtent

CDC::TabbedTextOut

GetTabbedTextExtent

CSize Class

Other Resources

CDC Members