DrawText 问题

Tasehouny 2003-01-07 05:30:28
当我用 CDC 的DrawText 函数画一个字符串时,我指定了一个RECT,当我给定的属性是DT_WORDBREAK时,我能知道,这个字符串画出来有几行吗?


当然,我的目的是在我画这个字符串之前,我就知道最终画出来是几行,这样,我就能分配合适大小的RECT区域给DrawText.

我现在只能知道,字符串有多多高,有多长,但将会有多少行,就请各位指点了!
...全文
77 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tasehouny 2003-01-07
  • 打赏
  • 举报
回复
谢谢!

DT_CALCRECT
zswzwy 2003-01-07
  • 打赏
  • 举报
回复
算算吧.
demetry 2003-01-07
  • 打赏
  • 举报
回复
需要自己计算
liu_feng_fly 2003-01-07
  • 打赏
  • 举报
回复
恐怕不能,这个函数是根据你给定的rect来动态判断输出几行的,和你传进去的rect有关。不过,如果你指定了
DT_CALCRECT Determines the width and height of the rectangle. If there are multiple lines of text, DrawText will use the width of the rectangle pointed to by lpRect and extend the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText will modify the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text, but does not draw the text.
这样,就可以根据给定的宽度计算出来有多高

15,979

社区成员

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

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