Need the smallest bound of RichTextBoxText

S

SamSpade

Given a RichTextBox I need to be able to determine the smallest rectangle
that bounds the text. In other words the size of the smallest paper it would
fit on.

For example, if the box contains text only I need to know the width of the
longest line as displayed and the height of all the text.

If it contains one image I need to know the width and height of the image.

Is that possible to determine?


Thanks
 
W

William DePalo [MVP VC++]

SamSpade said:
Given a RichTextBox I need to be able to determine the smallest rectangle
that bounds the text. In other words the size of the smallest paper it would
fit on.

At the level of the Win32 API you probably want to take a look at DrawText()
using the DT_CALCRECT and DT_EDITCONTROL flags.

Regards,
Will
 
S

SamSpade

Thanks. Are you thinking of me using DrawText or DrawTextEx.

Think it understands RTF?

Also, as I read the little doc I have in Help it seems to me that at best I
might be able to get is the height, but not the width (unless the text is 1
line). If I'm wrong please let me know since I have no way to go now.

Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top