Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

Cant figure out how to scroll text written with DrawText()

I cant figure out how to scroll text written with DrawText() when it is word wrapped using the DT_WORDBREAK option.  As far as I can tell, you need to know the number of lines in the text in order to scroll correctly, but I can't figure out how to get the number of lines of text when it is word wrapped.  Anyone have any experience with this?
0
lwinkenb
Asked:
lwinkenb
1 Solution
 
softplusCommented:
Use DrawText with DT_CALCRECT:
"DT_CALCRECT     Determines the width and height of the rectangle. If there are multiple lines of text, DrawText uses the width of the rectangle pointed to by the lpRect parameter and extends the base of the rectangle to bound the last line of text. If the largest word is wider than the rectangle, the width is expanded. If the text is less than the width of the rectangle, the width is reduced. If there is only one line of text, DrawText modifies 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." (from MSDN)
So define your rectangle with the width you want, leave the height 0 -> on return you can check the height :)

0
 
lwinkenbAuthor Commented:
Thanks, I was able to do it using DT_CALCRECT
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now