Showmessage MessageBox MessageDlg long string lazarus / 31-LCL ---------------------------------------------------------------------- k1attila1 · 2017-04-20 17:08 Hello Showmessage, MessageBox, MessageDlg wrap/break the line if string is long (eg 100 char) Does anybody know any solution or it is OS problem (Win10) ? thank you Attila ---------------------------------------------------------------------- Handoko · 2017-04-20 18:04 Tested ShowMessage's wrapping behavior on Lazarus 1.6.4 FPC 3.0.2 on my Ubuntu Mate 16.10 computer. And this is the test result: - The message will be wrapped on char 32 if the line is too long. - The message won't be wrapped nor truncated even it exceeds my screen width, if the string doesn't contain space (chr 32). This is the code I used: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Dialogs, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  i: Integer;  S: string;begin   S := '';  for i := 1 to 20 do    S := S + IntToStr(i)+'-123456 '; // has chr 32  ShowMessage(S);   S := '';  for i := 1 to 20 do    S := S + IntToStr(i)+'-123456x'; // no chr 32  ShowMessage(S); end; end. ---------------------------------------------------------------------- ASerge · 2017-04-20 18:36 Quote from: k1attila1 on April 20, 2017, 07:08:45 pmDoes anybody know any solution or it is OS problem (Win10) ? What is solution? My test. Windows 7 x64. Dialogs.ShowMessage, Application.MessageBox, Dialogs.MessageDlg wrap after 59 chars if text contain space, or show 56 chars with '...' on single line without wrap. Windows.MessageBox always wrap text. After 73 chars or early, if text contain space. ---------------------------------------------------------------------- Handoko · 2017-04-20 18:53 So the ShowMessage's behavior is OS depended. My test never got a '...' even the string's length is 491 (for i := 1 to 50). ---------------------------------------------------------------------- k1attila1 · 2017-04-21 03:34 Thank You So it is OS problem and not Lazarus. Thank You again Attila ---------------------------------------------------------------------- balazsszekely · 2017-04-21 04:34 Hi Attila, Try the following code, it works on my win10: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function MessageDlgEx(const AMsg: string; ADlgType: TMsgDlgType;  AButtons: TMsgDlgButtons; AParent: TForm): TModalResult;var  MsgFrm: TForm;begin  MsgFrm := CreateMessageDialog(AMsg, ADlgType, AButtons);  try    MsgFrm.Position := poDefaultSizeOnly;    MsgFrm.FormStyle := fsSystemStayOnTop;    MsgFrm.Left := AParent.Left + (AParent.Width - MsgFrm.Width) div 2;    MsgFrm.Top := AParent.Top + (AParent.Height - MsgFrm.Height) div 2;    Result := MsgFrm.ShowModal;  finally    MsgFrm.Free  end;end; procedure TForm1.Button1Click(Sender: TObject);begin  MessageDlgEx('fadfa afdfad afdad fafsd faf af af ads dddddddddddddddddddddddd dddddddddddddddddddddddd dddddddddddddddddddddddd dafdsad fasdfa daf',                mtInformation, [mbOk], Form1);end; ---------------------------------------------------------------------- k1attila1 · 2017-04-21 05:16 Thank you , Sir ! It is a good solution. Attila ---------------------------------------------------------------------- Zoran · 2017-04-21 06:47 Another solution is to replace spaces with non-breaking spaces: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  NonBreakingSpace: String = Char($C2) + Char($A0); // non-breaking space (utf8-encoded) procedure MyShowMessage(const aMsg: String);begin  ShowMessage(StringReplace(aMsg, Char(32), NonBreakingSpace, [rfReplaceAll]));end; function MyMessageDlg(const aMsg: string; DlgType: TMsgDlgType;            Buttons: TMsgDlgButtons; HelpCtx: Longint): TModalResult;begin  Result := MessageDlg(StringReplace(aMsg, Char(32), NonBreakingSpace, [rfReplaceAll]),    DlgType, Buttons, HelpCtx);end;   EDIT: No, GetMem's solution is better, as line breaking occurs not only on spaces, but also on other charactes which can appear in your message (dashes, tabs, ...), and these aren't handled by my code. ---------------------------------------------------------------------- k1attila1 · 2017-04-21 09:07 Thank you Zoran ! I study your solution too ,maybe useful for another problem. Attila