GetTextExtentExPointI function (wingdi.h)
The GetTextExtentExPointI function retrieves the number of characters in a specified string that will fit within a specified space and fills an array with the text extent for each of those characters. (A text extent is the distance between the beginning of the space and a character that will fit in the space.) This information is useful for word-wrapping calculations.
Syntax
BOOL GetTextExtentExPointI(
[in] HDC hdc,
[in] LPWORD lpwszString,
[in] int cwchString,
[in] int nMaxExtent,
[out] LPINT lpnFit,
[out] LPINT lpnDx,
[out] LPSIZE lpSize
);
Parameters
[in] hdc
A handle to the device context.
[in] lpwszString
A pointer to an array of glyph indices for which extents are to be retrieved.
[in] cwchString
The number of glyphs in the array pointed to by the pgiIn parameter.
[in] nMaxExtent
The maximum allowable width, in logical units, of the formatted string.
[out] lpnFit
A pointer to an integer that receives a count of the maximum number of characters that will fit in the space specified by the nMaxExtent parameter. When the lpnFit parameter is NULL, the nMaxExtent parameter is ignored.
[out] lpnDx
A pointer to an array of integers that receives partial glyph extents. Each element in the array gives the distance, in logical units, between the beginning of the glyph indices array and one of the glyphs that fits in the space specified by the nMaxExtent parameter. Although this array should have at least as many elements as glyph indices specified by the cgi parameter, the function fills the array with extents only for as many glyph indices as are specified by the lpnFit parameter. If lpnFit is NULL, the function does not compute partial string widths.
[out] lpSize
A pointer to a SIZE structure that receives the dimensions of the glyph indices array, in logical units. This value cannot be NULL.
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Remarks
If both the lpnFit and alpDx parameters are NULL, calling the GetTextExtentExPointI function is equivalent to calling the GetTextExtentPointI function.
When this function returns the text extent, it 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 you use a font that specifies a nonzero escapement, this function doesn't use the angle while it computes the text extent. The app must convert it explicitly. However, when the graphics mode is set to GM_ADVANCED and the character orientation is 90 degrees from the print orientation, the values that this function return do not follow this rule. When the character orientation and the print orientation match for a given string, this function returns the dimensions of the string in the SIZE structure as { cx : 116, cy : 18 }. When the character orientation and the print orientation are 90 degrees apart for the same string, this function returns the dimensions of the string in the SIZE structure as { cx : 18, cy : 116 }.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | wingdi.h (include Windows.h) |
Library | Gdi32.lib |
DLL | Gdi32.dll |