GetTextExtent

Syntax

DWORD GetTextExtent(hDC,lpString,nCount)

This function computes the width and height of the line of text pointed to by the lpString parameter. The GetTextExtent function uses the currently selected font to compute the dimensions of the string. The width and height (in logical units) are computed without considering the current clipping region.

Parameter Type/Description  

hDC HDC Identifies the device context.  
lpString LPSTR Points to a text string.  
nCount int Specifies the number of characters in the text string.  

Return Value

The return value specifies the dimensions of the string. The height is in the high-order word; the width is in the low-order word.

Comments

Since some devices do not place characters in regular cell arrays (that is, 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.