求个api函数

bulletCoderHope 2006-09-28 06:11:59
想实现的功能如下:
要设置datagrid或者是mshflexgrid中的cell刚好容纳本列中最长的文本
就是想通过此api得到某个文本的在固定的某个fontsize值下的宽度,转换为twip就可以实现这个功能

...全文
158 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bulletCoderHope 2006-09-28
  • 打赏
  • 举报
回复
3 q ,I gonna` check it
Hassle 2006-09-28
  • 打赏
  • 举报
回复
GetTextExtentPoint32
The GetTextExtentPoint32 function computes the width and height of the specified string of text.

BOOL GetTextExtentPoint32(
HDC hdc, // handle to device context
LPCTSTR lpString, // pointer to text string
int cbString, // number of characters in string
LPSIZE lpSize // pointer to structure for string size
);

Parameters
hdc
Handle to the device context.
lpString
Pointer to the string of text. The string does not need to be zero-terminated, since cbString specifies the length of the string.
cbString
Specifies the number of characters in the string.
lpSize
Pointer to a SIZE structure in which the dimensions of the string are to be returned.
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, callGetLastError.

Remarks
The GetTextExtentPoint32 function uses the currently selected font to compute the dimensions of the string. The width and height, in logical units, are computed without considering any clipping.

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

The calculated string width takes into account the intercharacter spacing set by the SetTextCharacterExtra function.

Windows CE: The GetTextExtentPoint32 function is identical to the GetTextExtentPoint function.


1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧