Recent

Author Topic: Can't stop it word wrapping  (Read 2055 times)

geraldholdsworth

  • Full Member
  • ***
  • Posts: 214
Can't stop it word wrapping
« on: May 06, 2023, 08:34:37 pm »
Hi all,

I'm trying to add formatted text to a RichMemo, which goes beyond the width of the control, and it keeps word wrapping. If I extend the width of the control, during run-time, it still wraps at the width it had at design time. I have set WordWrap to False, and ScrollBars to AutoBoth (both at design time and at run time), but this makes no difference. It also happens if I just do Lines.Add(<string>) that is longer than the width available.

I'm using Lazarus v2.2.0 on macOS Catalina. I have no idea what version RichMemo I'm using.

Cheers,

Gerald.

ASBzone

  • Hero Member
  • *****
  • Posts: 711
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: Can't stop it word wrapping
« Reply #1 on: May 07, 2023, 04:08:13 pm »
Can you provide a small running code example that demonstrates what you are experiencing?
-ASB: https://www.BrainWaveCC.com/

Lazarus v3.5.0.0 (2216170cde) / FPC v3.2.3-1387-g3795cadbc8
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

geraldholdsworth

  • Full Member
  • ***
  • Posts: 214
Re: Can't stop it word wrapping
« Reply #2 on: May 07, 2023, 09:54:17 pm »
This is what I'm playing with. The RichMemo is Client aligned, and both it and the form are 320px wide in design time.
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
  9.  RichMemo;
  10.  
  11. type
  12.  
  13.  { TForm1 }
  14.  
  15.  TForm1 = class(TForm)
  16.   Button1: TButton;
  17.   Panel1: TPanel;
  18.   RichMemo1: TRichMemo;
  19.   procedure Button1Click(Sender: TObject);
  20.  private
  21.  
  22.  public
  23.  
  24.  end;
  25.  
  26. var
  27.  Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.lfm}
  32.  
  33. { TForm1 }
  34.  
  35. procedure TForm1.Button1Click(Sender: TObject);
  36.  procedure AddColorStr(s: string; const col: TColor=clBlack;
  37.                                                    const NewLine: boolean=true);
  38.  begin
  39.   with RichMemo1 do
  40.   begin
  41.    if NewLine then
  42.    begin
  43.     if RichMemo1.Lines.Count=0 then
  44.     begin
  45.      RichMemo1.Lines.Add('');
  46.      Lines.Delete(Lines.Count-1);
  47.     end
  48.     else AddColorStr(#$0D#$0A,clBlack,False);
  49.    end;
  50.    SelStart :=Length(Text);
  51.    SelText  :=s;
  52.    SelLength:=Length(s);
  53.    SetRangeColor(SelStart,SelLength,col);
  54.    SelStart :=Length(Text);
  55.    SelText  :='';
  56.   end;
  57.  end;
  58. begin
  59.  AddColorStr('Black, ');
  60.  AddColorStr('Green, '  ,$00FF00,false);
  61.  AddColorStr('Blue, '   ,$FF0000,false);
  62.  AddColorStr('Red, '    ,$0000FF,false);
  63.  AddColorStr('Yellow, ' ,$00FFFF,False);
  64.  AddColorStr('Magenta, ',$FF00FF,false);
  65.  AddColorStr('Cyan, '   ,$FFFF00,false);
  66.  AddColorStr('Black, '  ,$000000,false);
  67.  AddColorStr('Green, '  ,$00FF00,false);
  68.  AddColorStr('Blue, '   ,$FF0000,false);
  69.  AddColorStr('Red, '    ,$0000FF,false);
  70.  AddColorStr('Yellow, ' ,$00FFFF,False);
  71.  AddColorStr('Magenta, ',$FF00FF,false);
  72.  AddColorStr('Cyan'     ,$FFFF00,false);
  73. end;
  74.  
  75. end.
  76.  

 

TinyPortal © 2005-2018