Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7085991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:29:38+00:00 2026-05-28T07:29:38+00:00

I use TRichEdit to edit text. I have WordWrap turned on which automatically wraps

  • 0

I use TRichEdit to edit text. I have WordWrap turned on which automatically wraps text at the edge of control so that there are no scroll-bars. RichEdit width is set to fit 80 columns.

WordWrap simulates this behaviour nicely as long as you have occasional space between words. But if you have a very loooooooooooooooooong word RichEdit wrap will break it automatically and WordWrap won’t!

If I want now to access these wrapped lines I can get it through RichEdit.Lines.Text which will put automatically CRLF at column 80. If I use RichEdit.Text I get raw text with no CRLF suitable for WordWrap.

The task is not trivial to do in a custom function as I already tried and it was not a small function but might there be a way to use wrapping functions of TRichEdit? I have an idea to create hidden RichEdit but that kind of seems stupid for this task as I would have to calculate its width just to do wordwrapping – rather pointless I think.

The question – is there a way to force WordWrap to cut long words that cannot be wrapped otherwise? So if a word is 170 characters long, it would be wrapped into 3 lines 80 + 80 + 10 but also taking care of words before to fill previous and following lines?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:29:38+00:00Added an answer on May 28, 2026 at 7:29 am

    Try this on for size:

    procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
    const
       MAX_LENGTH = 80;
    var
      nLineCount:   integer;
      sCurrentLine: string;
    begin
      for nLineCount := 0 to RichEdit1.Lines.Count - 1 do
      begin
        // no space in this line
        if (pos(' ',RichEdit1.Lines.Strings[nLineCount]) = 0) then
        begin
          if (length(RichEdit1.Lines.Strings[nLineCount]) > MAX_LENGTH) then
          begin
            // hold the whole line
            sCurrentLine := RichEdit1.Lines.Strings[nLineCount];
            // the current line, make the max value
            RichEdit1.Lines.Strings[nLineCount] := copy(sCurrentLine,1,MAX_LENGTH);
            // build the next line
            RichEdit1.Lines.Add(
            copy(sCurrentLine,MAX_LENGTH + 1,1));
          end;
        end;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use scenario is pretty simple: I have a desktop only application that could be
use case example I have a servlet that is receiving login requests. If a
Use case: we have some project meta-data files which we want tracked, but are
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Use case: 3rd party application wants to programatically monitor a text file being generated
Use case: I've just entered insert mode, and typed some text. Now I want
We use a data acquisition card to take readings from a device that increases
Problem If the text in TRichEdit is something like this; 'hello, world'#$D#$A Then the
use Control::CLI; $cli = new Control::CLI('SSH'); $cli->connect(Host=>'10.10.10.10',Username=>'user',Password=>'pwd'); $cli->waitfor('>'); $cli->print('Show XXXXXXXXXXXXXXXXXXXX| grep Active'); @f=$cli->waitfor('>'); print
use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get( $url ); say $mech->text; How could I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.