Condividi tramite


CDC::GetOutputTextExtent

Call this member function to use the output device context, m_hDC, and compute the width and height of a line of text, using the current font.

CSize GetOutputTextExtent(
   LPCTSTR lpszString,
   int nCount 
) const;
CSize GetOutputTextExtent(
   const CString& str 
) const;

Parameters

  • lpszString
    Points to a string of characters. You can also pass a CString object for this parameter.

  • nCount
    Specifies the number of characters in the string. If nCount is –1, the length is calculated.

  • str
    A CString object that contains the specified characters to be measured.

Return Value

The dimensions of the string (in logical units) returned in a CSize object.

Remarks

The current clipping region does not affect the width and height returned by GetOutputTextExtent.

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.

Requirements

Header: afxwin.h

See Also

Reference

CDC Class

Hierarchy Chart

CDC::GetTabbedTextExtent

CDC::GetOutputTabbedTextExtent

CDC::m_hAttribDC

CDC::m_hDC

CDC::GetTextExtent

CDC::SetTextJustification

CSize Class

Other Resources

CDC Members