GetTextExtentExPoint

  BOOL GetTextExtentExPoint(hdc, lpszString, cchString, nMaxExtent, lpnFit, alpDx, lpSize)    
  HDC hdc; /* device-context handle */
  LPCTSTR lpszString; /* pointer to string */
  int cchString; /* number of characters in string */
  int nMaxExtent; /* maximum width for formatted string */
  LPINT lpnFit; /* pointer to int for chars fitting in max extent */
  LPINT alpDx; /* pointer to array for partial string widths */
  LPSIZE lpSize; /* pointer to SIZE for string dimensions */

The GetTextExtentExPoint function retrieves the number of characters in a specified string that will fit within a given space and fills an array with text extents for those characters. Each text extent gives the distance between the beginning of the space and each character that will fit in the space. This information is useful for word-wrapping calculations.

Parameters

hdc

Identifies the device context.

lpszString

Points to a null-terminated string for which extents are retrieved.

cchString

Specifies the number of bytes in the string pointed to by the lpszString parameter.

nMaxExtent

Specifies the maximum width (in logical units) for the formatted string.

lpnFit

Points to an integer specifying, when the function returns, the number of characters that will fit in the space given by the nMaxExtent parameter. When the lpnFit parameter is NULL, the nMaxExtent parameter is ignored.

alpDx

Points to an array of integers that contains partial string extents when the function returns. Each element in the array gives the distance (in logical units) between the beginning of the string and one of the characters that fits in the space specified by the nMaxExtent parameter. Although this array should have at least as many elements as characters specified by the cchString parameter, the function fills the array with extents only for as many characters as are given by the lpnFit parameter. If alpDx is NULL, the function does not compute partial string widths.

lpSize

Points to a SIZE structure that contains the dimensions of the string (in logical units) when the function returns. The width is in the cx field and the height is in the cy field. This may not be NULL.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. To obtain extended error information, use the GetLastError function.

Comments

If both the lpnFit and alpDx parameters are NULL, the GetTextExtentExPoint function is equivalent to GetTextExtentPoint.

See Also

GetTextExtentPoint