GetTextExtentPoint

3.1

  BOOL GetTextExtentPoint(hdc, lpszString, cbString, lpSize)    
  HDC hdc; /* handle of device context */
  LPCSTR lpszString; /* address of text string */
  int cbString; /* number of bytes in string */
  SIZE FAR* lpSize; /* address if structure for string size */

The GetTextExtentPoint function computes the width and height of the specified text string. The GetTextExtentPoint function uses the currently selected font to compute the dimensions of the string. The width and height, in logical units, are computed without considering any clipping.

The GetTextExtentPoint 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).

Parameters

hdc

Identifies the device context.

lpszString

Points to a text string.

cbString

Specifies the number of bytes in the text string.

lpSize

Points to a SIZE structure that will receive the dimensions of the string The SIZE structure has the following form:

typedef struct tagSIZE {
    int cx;
    int cy;
} SIZE;

For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Comments

Because some devices do not place characters in regular cell arrays—that is, because they carry out kerning—the sum of the extents of the characters in a string may not be equal to the extent of the string.

The calculated width takes into account the intercharacter spacing set by the SetTextCharacterExtra function.

See Also

SetTextCharacterExtra