|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Call this member function to compute the width and height of a line of text using the current font to determine the dimensions.
CSize GetTextExtent( LPCTSTR lpszString, int nCount ) const; CSize GetTextExtent( const CString& str ) const;
- Points to a string of characters. You can also pass a CString object for this parameter.
- Specifies the number of characters in the string.
- A CString object that contains the specified characters.
The dimensions of the string (in logical units) in a CSize object.
The information is retrieved from m_hAttribDC, the attribute device context.
By default, GetTextExtent assumes the text for which it retrieves the dimension is set along a horizontal line (that is, the escapement is 0). If you create a font specifying a non-zero escapement, you must convert the angle of the text explicitly to get the dimensions of the string.
The current clipping region does not affect the width and height returned by GetTextExtent.
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.