Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function computes the width and height of the specified string of text.

Syntax

BOOL GetTextExtentPoint( 
  HDC 
hdc, 
  LPCTSTR 
lpString, 
  int 
cbString, 
  LPSIZE 
lpSize
);

Parameters

hdc

[in] Handle to the device context (DC).

lpString

[in] Long pointer to the string of text. The string does not need to be zero-terminated because cbStringspecifies the length of the string.

cbString

[in] Integer that specifies the number of characters in the string.

lpSize

[out] Long pointer to a SIZEstructure that receives the dimensions of the string.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

The GetTextExtentPointfunction uses the currently selected font to compute the dimensions of the string. GetTextExtentPointcomputes the width and height, in logical units, without considering any clipping.

Because some devices kern characters, the sum of the extents of the characters in a string does not always equal to the extent of the string.

The GetTextExtentPointfunction is identical to the GetTextExtentPoint32function.

Requirements

Header windows.h
Library coredll.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

GetTextExtentPoint32

Other Resources

SIZE