This topic has not yet been rated - Rate this topic

GetTabbedTextExtent function

Applies to: desktop apps only

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 specified tab stops. The GetTabbedTextExtent function uses the currently selected font to compute the dimensions of the string.

Syntax

DWORD GetTabbedTextExtent(
  __in  HDC hDC,
  __in  LPCTSTR lpString,
  __in  int nCount,
  __in  int nTabPositions,
  __in  const LPINT lpnTabStopPositions
);

Parameters

hDC [in]

A handle to the device context.

lpString [in]

A pointer to a character string.

nCount [in]

The length of the text string. For the ANSI function it is a BYTE count and for the Unicode function it is a WORD count. Note that for the ANSI function, characters in SBCS code pages take one byte each, while most characters in DBCS code pages take two bytes; for the Unicode function, most currently defined Unicode characters (those in the Basic Multilingual Plane (BMP)) are one WORD while Unicode surrogates are two WORDs.

nTabPositions [in]

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

lpnTabStopPositions [in]

A pointer 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

If the function succeeds, the return value is 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.

If the function fails, the return value is 0. GetTabbedTextExtent will fail if hDC is invalid and if nTabPositions is less than 0.

Remarks

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

Because 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.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

Unicode and ANSI names

GetTabbedTextExtentW (Unicode) and GetTabbedTextExtentA (ANSI)

See also

Fonts and Text Overview
Font and Text Functions
GetTextExtentPoint32
TabbedTextOut

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ