Need the smallest bound of RichTextBoxText

  • Thread starter Thread starter SamSpade
  • Start date Start date
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
 
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
 
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
 
Back
Top