请求解释一下VC++中GetTextMetrics函数和GetTextextent函数的区别?
2个回答
展开全部
1、
GetTextMetrics
The GetTextMetrics function fills the specified buffer with the metrics for the currently selected font.
BOOL GetTextMetrics(
HDC hdc, // handle to DC
LPTEXTMETRIC lptm // text metrics
);
Parameters
hdc
[in] Handle to the device context.
lptm
[out] Pointer to the TEXTMETRIC structure that receives the text metrics.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
2、
Call this member function to compute the width and height of a line of text using the current font to determine the dimensions.
CSize GetTextExtent(
LPCTSTR lpszString,
int nCount
) const;
CSize GetTextExtent(
const CString& str
) const;
Parameters
lpszString
Points to a string of characters. You can also pass a CString object for this parameter.
nCount
Specifies the number of characters in the string.
str
A CString object that contains the specified characters.
Return Value
The dimensions of the string (in logical units) in a CSize object.
GetTextMetrics
The GetTextMetrics function fills the specified buffer with the metrics for the currently selected font.
BOOL GetTextMetrics(
HDC hdc, // handle to DC
LPTEXTMETRIC lptm // text metrics
);
Parameters
hdc
[in] Handle to the device context.
lptm
[out] Pointer to the TEXTMETRIC structure that receives the text metrics.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
2、
Call this member function to compute the width and height of a line of text using the current font to determine the dimensions.
CSize GetTextExtent(
LPCTSTR lpszString,
int nCount
) const;
CSize GetTextExtent(
const CString& str
) const;
Parameters
lpszString
Points to a string of characters. You can also pass a CString object for this parameter.
nCount
Specifies the number of characters in the string.
str
A CString object that contains the specified characters.
Return Value
The dimensions of the string (in logical units) in a CSize object.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询