GetTextMetrics

The GetTextMetrics function fills the specified buffer with the metrics for the currently selected font.

BOOL GetTextMetrics(
  HDC hdc,            // handle to device context
  LPTEXTMETRIC lptm   // pointer to text metrics structure
);
 

Parameters

hdc
Handle to the device context.
lptm
Pointer to the TEXTMETRIC structure that is to receive the metrics.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Windows NT: To get extended error information, call GetLastError.

Remarks

Windows CE: For any given font, the text metric values in Windows CE will not necessarily match the text metric values in Windows desktop platforms.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in wingdi.h.
  Import Library: Use gdi32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

See Also

Fonts and Text Overview, Font and Text Functions, GetTextAlign, GetTextExtentPoint32, GetTextFace, SetTextJustification, TEXTMETRIC