GetTabbedTextExtent

  DWORD GetTabbedTextExtent(hdc, lpString, cchString, nTabPositions, lpnTabStopPositions)    
  HDC hdc; /* device-context handle */
  LPCTSTR lpString; /* pointer to string */
  int cchString; /* number of characters in string */
  int nTabPositions; /* number of tab positions */
  LPINT lpnTabStopPositions; /* pointer to array of tab positions */

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

Parameters

hdc

Identifies the device context.

lpString

Points to a character string.

cchString

Specifies the number of characters in the text string.

nTabPositions

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

lpnTabStopPositions

Points to an array containing the tab-stop positions (in device units). The tab stops must be sorted in increasing order; the smallest x-value should be the first item in the array.

Return Value

The return value specifies the dimensions of the string (in logical units). The height is in the high-order word and the width is in the low-order word.

Comments

The current clipping region does not affect 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 the nTabPositions parameter is zero and the lpnTabStopPositions parameter is NULL, tabs are expanded to eight times the average character width.

If nTabPositions is 1, the tab stops are separated by the distance specified by the first value in the array to which lpnTabStopPositions points.

The GetTabbedTextExtent function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

GetTextExtent, HIWORD, LOWORD, TabbedTextOut