GetCharWidth32

The GetCharWidth32 function retrieves the widths, in logical coordinates, of consecutive characters in a specified range from the current font.

BOOL GetCharWidth32(
  HDC hdc,         // handle to device context
  UINT iFirstChar, // first character in range to query
  UINT iLastChar,  // last character in range to query
  LPINT lpBuffer   // pointer to buffer for widths
);
 

Parameters

hdc
Handle to the device context.
iFirstChar
Specifies the first character in the group of consecutive characters.
iLastChar
Specifies the last character in the group of consecutive characters, which must not precede the specified first character.
lpBuffer
Pointer to a buffer to receive the widths.

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

The range is inclusive; that is, the returned widths include the widths of the characters specified by the iFirstChar and iLastChar parameters.

If a character does not exist in the current font, it is assigned the width of the default character.

QuickInfo

  Windows NT: Requires version 3.5 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  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, GetCharABCWidths, GetCharABCWidthsFloat, GetCharWidthFloat