Link to home
Create AccountLog in
Avatar of pmarkov
pmarkov

asked on

RichEdit width

Hello

I have an TRichEdit component with Wordwrap := False and PlainText := False;
There is text formated as Rich Text.

I have to determine the maximum witdth of my TRichEdit component and how can I auto-fit TRichEdit's width?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of pmarkov
pmarkov

ASKER

OK. Obvious I omit the details.

There are multiple lines in TRichEdit component. So because I set wordwrap to false there is horisontal scroll bar if the width of the RichEdit component is not enought.

I want to determine the length of the longnest line to set the TRichEdit's width to hold the line without  necessity to show horisontal scroll bar.

Is that enought?
Can`t you just set TRichEdit().ScrollBars to ssVertical?
Well to work out the longest line would be a bit of a pain considering it will also be dependant on the font you are using. Some fonts are smaller/bigger than others in width.

I would personally set vertical scroll bars like ZhaawZ said and turn word wrapping on. Do you have an issue with word wrapping?
Avatar of pmarkov

ASKER

I want to code a procedure for printing a TRichEdit's content, but I DO NOT want word wrapping. I want to split RE to multiple sheets as MS Excel does when printing large tables.

To do this, I would need to determine how many pages wide would be required. With that information, I would resize the RE rendering rectangle to match the number of printable pages.

So I have to calculate how many pages are necessary to use. If I know how long is the longnes line this would be fairly easy to do.

Well the only thing I could think of as a check would be to pysically calculate the textwidth of the line in the rich edit box (which returns a pixel length value which I guess you could compare with screen/page size)

Usually the TextWidth function is associated with a canvas but a richedit doesnt have one.
You could grab the value by using the forms canvas I think though someone else might be able to give you a better suggestion.

Form1.Canvas.TextWidth(RichEdit1.Text) returns a pixel integer value.

Then you could grab the canvas size of your printer/paper and compare
Printer.Canvas.Width/Height (uses you default printer I think)

Printer.Orientation you might need to set first as this will change the Width/Height properties.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of pmarkov

ASKER

What about this:

Is a good idea to create a *.jpg image from a TRichEdit (with enough width to prevent word-wrap) and then split this image and print each of them on different pages?