勇芳软件工作室.汉化:  Fonts and Text > Fonts and Text Functions >

GetCharWidth

Previous pageReturn to chapter overviewNext page

描述

 

GetCharWidth函数以逻辑坐标检索当前字体在指定范围内的连续字符的宽度。

 

注意此函数仅适用于与16位版本的Windows兼容。应用程序应调用GetCharWidth32功能,可提供更准确的结果。

 

C++ 语法

 

BOOL GetCharWidth(

__in  HDC hdc,

__in  UINT iFirstChar,

__in  UINT iLastChar,

__out LPINT lpBuffer

);

 

PowerBASIC 语法

 

FUNCTION GetCharWidthA ( _

BYVAL hdc AS DWORD, _

BYVAL iFirstChar AS DWORD, _

BYVAL iLastChar AS DWORD, _

BYREF lpBuffer AS LONG _

) AS LONG

 

Unicode版本:

 

FUNCTION GetCharWidthW ( _

BYVAL hdc AS DWORD, _

BYVAL iFirstChar AS DWORD, _

BYVAL iLastChar AS DWORD, _

BYREF lpBuffer AS LONG _

) AS LONG

 

参数

 

hdc

 

[in]处理设备上下文。

 

iFirstChar

 

[in]指定连续字符组中的第一个字符。

 

iLastChar

 

[in]指定连续字符组中的最后一个字符,不得超过指定的第一个字符。

 

lpBuffer

 

[out]指向以逻辑坐标接收字符宽度的缓冲区的指针。

 

返回值

 

如果函数成功,返回值不为零。

 

如果函数失败,返回值为零。

 

备注

 

GetCharWidth不能在TrueType字体上使用。要检索TrueType字体的字符宽度,请使用GetCharABCWidths.

 

范围是包容性的也就是说,返回的宽度包括iFirstChariLastChar参数指定的字符的宽度。

 

如果当前字体中不存在字符,则会分配默认字符的宽度。

 

Windows 95/98 / Me:即使Windows 95/98 / Me中存在GetCharWidthW,Microsoft Layer for Unicode也支持在所有Windows操作系统上提供更一致的行为。

 

引用文件 #INCLUDE Once

 

WinGdi.inc(包括Windows.inc)