GetTextExtentPointA function (wingdi.h)
The GetTextExtentPoint function computes the width and height of the specified string of text.
BOOL GetTextExtentPointA( [in] HDC hdc, [in] LPCSTR lpString, [in] int c, [out] LPSIZE lpsz );
A handle to the device context.
A pointer to the string that specifies the text. The string does not need to be zero-terminated, since cbString specifies the length of the string.
The length of the string pointed to by lpString.
A pointer to a SIZE structure that receives the dimensions of the string, in logical units.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
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. Also, this function assumes that the text is horizontal, that is, that the escapement is always 0. This is true for both the horizontal and vertical measurements of the text. Even if using a font specifying a nonzero escapement, this function will not use the angle while computing the text extent. The application must convert it explicitly.
Because some devices kern characters, the sum of the extents of the characters in a string may not be equal to the extent of the string.
The calculated string width takes into account the intercharacter spacing set by the SetTextCharacterExtra function.
The wingdi.h header defines GetTextExtentPoint as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|Header||wingdi.h (include Windows.h)|